[ANN] brieflz 0.1.0 - Lua binding for BriefLZ

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[ANN] brieflz 0.1.0 - Lua binding for BriefLZ

Jakub Jirutka
Hi,

I’m happy to announce the first release of brieflz [1] – Lua/C binding for BriefLZ [2], small and fast open source implementation of a Lempel-Ziv style compression algorithm by Joergen Ibsen.

BriefLZ is really very small C library, just 123 LoC compression code / 115 LoC safe decompression (or 63 LoC unsafe), and offers decent compression ratio. Of course it can’t compete in compression ratio with zlib or other “heavy” compression libraries, but it’s a good choice if you need good enough compression with minimal footprint. I found that it has much better compression ration on Lua sources than more known liblzf [3].

Just for very rough idea: 817 kiB Lua source (merged multiple sources, with a lot of comments) compressed to 243 kiB with BriefLZ, 337 kiB with liblzf, 207 kiB with gzip -9.

brieflz is available on LuaRocks [4] or as a tarball in the repository [1]. Documentation in ldoc is available on [5].

Jakub

[1]: https://github.com/jirutka/brieflz.lua
[2]: https://github.com/jibsen/brieflz
[3]: https://github.com/nemequ/liblzf
[4]: https://luarocks.org/modules/jirutka/brieflz
[5]: https://jirutka.github.io/brieflz.lua/ldoc/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ANN] brieflz 0.1.0 - Lua binding for BriefLZ

François Perrad


2017-07-19 16:24 GMT+02:00 Jakub Jirutka <[hidden email]>:
Hi,

I’m happy to announce the first release of brieflz [1] – Lua/C binding for BriefLZ [2], small and fast open source implementation of a Lempel-Ziv style compression algorithm by Joergen Ibsen.

BriefLZ is really very small C library, just 123 LoC compression code / 115 LoC safe decompression (or 63 LoC unsafe), and offers decent compression ratio. Of course it can’t compete in compression ratio with zlib or other “heavy” compression libraries, but it’s a good choice if you need good enough compression with minimal footprint. I found that it has much better compression ration on Lua sources than more known liblzf [3].

Just for very rough idea: 817 kiB Lua source (merged multiple sources, with a lot of comments) compressed to 243 kiB with BriefLZ, 337 kiB with liblzf, 207 kiB with gzip -9.

brieflz is available on LuaRocks [4] or as a tarball in the repository [1]. Documentation in ldoc is available on [5].


Hello Jakub,

A best practice is to use `lua_getallocf` instead of the C `malloc`/`free`.
By this way, your extension uses the same allocator than the Lua interpreter.
See the reference manual:
https://www.lua.org/manual/5.3/manual.html#lua_getallocf
https://www.lua.org/manual/5.3/manual.html#lua_Alloc
See an example:
https://github.com/fperrad/lua-csnappy/blob/master/lsnappy.c#L18-L35

François

 
Jakub

[1]: https://github.com/jirutka/brieflz.lua
[2]: https://github.com/jibsen/brieflz
[3]: https://github.com/nemequ/liblzf
[4]: https://luarocks.org/modules/jirutka/brieflz
[5]: https://jirutka.github.io/brieflz.lua/ldoc/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ANN] brieflz 0.1.0 - Lua binding for BriefLZ

Jakub Jirutka
Hi François,

Thanks you for your advice, I didn’t know about lua_getallocf / lua_Alloc! I’ve fixed it and released 0.1.1.

Jakub

On 23. Jul 2017, at 8:12, François Perrad <[hidden email]> wrote:

Hello Jakub,

A best practice is to use `lua_getallocf` instead of the C `malloc`/`free`.
By this way, your extension uses the same allocator than the Lua interpreter.
See the reference manual:
https://www.lua.org/manual/5.3/manual.html#lua_getallocf
https://www.lua.org/manual/5.3/manual.html#lua_Alloc
See an example:
https://github.com/fperrad/lua-csnappy/blob/master/lsnappy.c#L18-L35

François

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ANN] brieflz 0.1.0 - Lua binding for BriefLZ

Philipp Janda
In reply to this post by François Perrad
Hi!

Am 23.07.2017 um 08:12 schröbte François Perrad:

> 2017-07-19 16:24 GMT+02:00 Jakub Jirutka <[hidden email]>:
>
>> Hi,
>>
>> I’m happy to announce the first release of brieflz [1] – Lua/C binding for
>> BriefLZ [2], small and fast open source implementation of a Lempel-Ziv
>> style compression algorithm by Joergen Ibsen.
>>
>> BriefLZ is really very small C library, just 123 LoC compression code /
>> 115 LoC safe decompression (or 63 LoC unsafe), and offers decent
>> compression ratio. Of course it can’t compete in compression ratio with
>> zlib or other “heavy” compression libraries, but it’s a good choice if you
>> need good enough compression with minimal footprint. I found that it has
>> much better compression ration on Lua sources than more known liblzf [3].
>>
>> Just for very rough idea: 817 kiB Lua source (merged multiple sources,
>> with a lot of comments) compressed to 243 kiB with BriefLZ, 337 kiB with
>> liblzf, 207 kiB with gzip -9.
>>
>> brieflz is available on LuaRocks [4] or as a tarball in the repository
>> [1]. Documentation in ldoc is available on [5].
>>
>>
> Hello Jakub,
>
> A best practice is to use `lua_getallocf` instead of the C `malloc`/`free`.
> By this way, your extension uses the same allocator than the Lua
> interpreter.

I'd call it better practice. Best practive IMHO would be to use
`lua_newuserdata` directly to make the code exception-safe automatically.

>
> François

Philipp



Loading...