LZ4. GitHub repository here. It is open-source, available on pretty much every platform, and widely used in the industry.

It was extremely easy to get started with it. The C API could not possibly be any simpler (I’m looking at you zlib 😛 ); you pass in 4 parameters to the compression and decompression functions: input buffer, input length, output buffer, and max output length. They return either the number of bytes produced on the output, or an error code. Just be careful when compressing random data (which you should not be doing anyways!): the output is larger than the input!

Here’s a short example that compresses a vector of thousand characters:

compression.cpp:

LZ4 compress, bytes in: 1000, bytes out: 14
LZ4 decompress, bytes in: 14, bytes out: 1000
Decompressed data matches original :o)

Program output.

5 Replies to “Extremely Fast Compression Algorithm”

          1. we all read the blog 🙂
            Sounds good, I’ll have some ideas.
            I can’ remember if you already had stuff related to future/promise.

Leave a Reply