Ask HN: LZ4 was not added as an optional compressor in HTTP/2, why gzip only?
So, pretty much everyone agrees that LZ4 is a superior codec for on-the-fly compression of data, and works especially well with HTML and XML and JSON.
Yet, we still only allow gzip for HTTP compression. What gives? I use gzip -9 + advdef -z -4 -i 1000 + nginx's gzip_static for static resources; but with dynamic HTML, I'm stuck with gzip -1 (with anything more, compression tends to take longer than the data saved wrt a modern Internet connection (>10mbps)).
LZ4 would perform better here and require less CPU on the remote side (not a big thing on desktops and laptops, but a huge thing on cell phones and such), so why did Google and Mozilla and the IETF working group overlook this?
(
11 comments
| 15 points
| on HN
)
LZ4 might be better at compressing, but it has worse performance characteristics. But don't take my word for it:
http://catchchallenger.first-world.info//wiki/Quick_Benchmar...
As you can see, LZ4 uses 30x as much memory as gzip.
It measures memory usage from the lz4 command line utility, without mentioning it. This is completely different from lz4 algorithm.
Effectively, it measures input / output buffers, which are external to lz4. Plus it uses highest settings for such buffers, also without mentioning it. Using -B4 setting, for example, would reduce I/O buffer memory by a 50X factor.
lz4 itself uses only 16KB for compression.
And that doesn't answer my question: I'm okay with gzip also being allowed, but the whole entire reason we allow multiple compressors is so the web browser and the web server can negotiate what features are supported.
Low memory HTTP clients, yes, can continue to use gzip. But the rest of us, why are we not using LZ4? I mean, hell, there is no reason why HTTP 1.0 and 1.1 clients can't also support LZ4 as well: they just have to negotiate for the feature.
Memory access costs power and time (which = power too).
It's bad enough that desktop browsers like chrome are complete memory hogs without stuff like this, I hate to imagine what a phone browser would be like if "fuck it, modern phones have heaps of resources" was the approach to all decisions.
Next you'll be suggesting a compression algorithm that only works anywhere near realtime when it has 8x1ghz+ cores to spread the work over.
and that's it. Decompression doesn't use any memory, only the I/O buffers.
On the compression side, the memory cost is : + buffer for compression (typically == size of data to compress) + 16 KB for tables
And that's it.
We are very very far from the 12 MB mentioned.
> Memory usage isn't that big of a concern anymore
Also 12MB of memory used on compression (as seen in Someone1234's link) would be pretty bad for a web server.
Edit: Also, do phones have trouble keeping up with gzip decompression? Isn't it layout that's the limiting factor?
For example, the Linux kernel can use LZ4, corporate VPN solutions like OpenVPN can use LZ4, and many other things can use or require LZ4.