LZHAM – Lossless compression with faster decompression than LZMA
code.google.com
code.google.com
Does the algorithm run well on ARM?
He mentions later that he's using a "Core i7 970", which is from the Westmere generation that came out in 2010. The decompression speed on the more modern Sandy Bridge, Ivy Bridge, Haswell, or Broadwell chips could be anywhere from the same to 8x better depending on how amenable the algorithm is SIMD improvements.
Without testing it's hard to know, but my guess would be that since it was not consciously designed to take advantage of the newer processor features, it probably will be at the low end of this, and could be beaten handily by an approach that targets only new instruction sets.
Nevertheless, an article comparing the speed and compression efficiency of these algorithms could be interesting.
[1] https://code.google.com/p/lz4/
[2] http://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Ober...
LZ4, by comparison, had compressed sizes of 40.88 MiB and 362.40 MiB. A database or a Linux distribution using zswap/zram/etc. would be able to store 84% more data in the same amount of memory. For caches, that's huge.
Here are the table rows:
lzham alpha 3 x64 -m4 -d29 24,954,329 206,393,809 155,282 x 206,549,091 595 9 4800 LZ77 45
lz4 v1.2 -c2 42,870,164 379,999,522 49,128 x 380,048,650 91 6 20 LZ77 26
One trade-off appears to be that lzham often requires a larger dictionary in memory, but it appears that even with smaller dictionary sizes it is appreciably more compact than lz4.Static but commonly downloaded data is already cached. For downloading software packages, or differential sofware updates (e.g. initializing the dictionary with previously downloaded elements), it would make a lot of sense (basically, the things that are already being done with LZMA getting extra speed).
It will take time to get LZHAM as stable as LZMA. It looks promising, anyway.
I was trying to refer to things that are downloaded by a lot of people (such as our 3D scenes here: https://clara.io/library), rather than something that is repeatedly downloaded by a single person.
Downloading the data to these 3D scenes is by far the slowest thing and we know that LZMA variants lead to nearly 2x reduction in data transfer.
Why is it better than bzip2, or gzip? Both of these are 2-3x faster than LZMA (much more so for gzip --fast) but have lower compression ratios.
LZ4 would be the extreme example of an algorithm even faster than gzip (but with still lower compression ratio).
The authors of PAQ, LZ4 and everything in between hang out on that board and talk compression.
Compression Compressed size Decompresser Total size Time (ns/byte)
Program Options enwik8 enwik9 size (zip) enwik9+prog Comp Decomp Mem Alg Note
lzham alpha 3 x64 -m4 -d29 24,954,329 206,393,809 155,282 x 206,549,091 595 9 4800 LZ77 45
gzip 1.3.5 -9 36,445,248 322,591,995 38,801 x 322,630,796 101 17 1.6 LZ77
bzip2 1.0.2 -9 29,008,736 253,977,839 30,036 x 254,007,875 379 129 8 BWT
Salient point is the decompression time (ns/byte), which is 129 for bzip2, 17 for gzip, and... 9 (!) for lzham. So on that point it blows them out of the water, while still achieving higher compression rate on this type of input. As the original webpage implies, this is perfect for stuff like video games.Much better than lz4hc (7 ns/byte, but only compresses to 44MB):
lz4hc 0.9 44,182,558 392,102,544 43,617 x 392,146,161 65 7 14 LZ77 26
For anyone publishing compression benchmarks: Please, please include memory usage in the report! Very few reports bother to do so at the moment. Meanwhile, many compressors take the assumption that since 16 gigs of RAM is cheap these days, that means using a few extra gigs to get a speedup is totally reasonable. It may be reasonable for you, but it makes the algo useless for me.
While bzip2 is faster at compressing and has lower memory requirements, LZMA can beat it at decompressing speed by large margins.
This is of course nowhere near LZ4.
Disclosure: I'm probably the only person to release a game that uses LZHAM other than Rich… I chose it because because I needed an LZMA-like compression ratio with a faster decompressor. Performed up to expectations.
decompresion ~100MB/s
color me unimpressed :(