Chrome Feature: ZSTD Content-Encoding
chromestatus.com
chromestatus.com
I made this change coincidentally, the day before the xz compromise.
ZSTD 3 is nearly as fast as LZ4 while getting a much better ratio. Consiquentially, on my linux boxes I use either ZFS or btrfs and use zstd 3 as the default for the file system.
Zstd is often "fast enough" in decompression for most cases, though.
https://raw.githubusercontent.com/facebook/zstd/dev/CHANGELO...
See v1.3.0
I compile it statically without xz/lzma support
Personally, as someone who doesn't work in web, I'm just as happy that zstd is flexible this way. For my applications, the brotli dictionary is pure overhead that bloats the library.
They want _every zstd decompressor_ to __already have__ the dictionary in question so that it can be specified as part of the standard. E.G. 'instead of empty / an initial in file dictionary, use the standard dict #3' Such reference dictionary starts would be not be included in .zstd files, but would be shipped with the compressor source code.
> Typical gains range ~10% (at 64KB) to x5 better (at <1KB).
https://www.manpagez.com/man/1/zstd/zstd-1.1.0.php
Files distributed by distros are unlikely to have many packages < 64kib so the advantages of a dictionary rapidly diminish on this use-case.
The brotli dictionary appears to help with random text, not just html/css.
https://github.com/facebook/zstd/issues/3100
This was the first place my mind went when I saw this Content-Encoding announcement, so I ran and re-checked the issue :(.
Edit: Actually this is already considered in RFC-8878 [0]. The RFC reserves zstd frame dictionary ids in the ranges: <= 32767 and >= (1 << 31) for a public IANA dictionary registry, but there are no such dictionaries published for public use yet.
[0]: https://datatracker.ietf.org/doc/html/rfc8878#iana_dict
Still seems a bit complicated to me, but could be meaningful for web apps that are required to be large.
The difference between brotli and zstd is 2.2ms at the 95th percentile, at lower percentiles the differences are much smaller. This is still an area of active investigation/development for us. There are possibly content sizes where one is better than another. There are also probably tweaks on the server-side to improve the encoding time.
For the rest of us, another half-decade+ wait to get useful levels of compatibility especially on mobile
Chrome already ships it with their currently released browsers, so you get a significant amount of mobile traffic (about 42%) from Android devices supporting it already. I don't know what the current status of Blink on iOS is, but once that releases, you'll also get iOS users.
WebKit has reacted positively to the proposal, though the Github issue documenting their position refers to an internal radar ticket so I have no idea what their timeline is.
If you build for Chrome today, compatibility will only grow. Chrome doesn't do compression levels above a certain point but I doubt Safari and Firefox will be affected by a different limitation when support eventually lands.
Plus, if your web server is configured well, you can have the gzip/brotli/zstd content available right next to each other, and just follow the browser's preference to pick a supported compressed asset.
There really are no downsides here.
Or you could build your site properly and have it work on more than a single browser.
You do you.
If Firefox and Webkit do introduce compatibility issues, you can always correct those later, though I doubt there will be any.
The dictionary feature [2] will help design some new ways of getting small resources.
[1] https://news.ycombinator.com/item?id=39793805
[2] https://facebook.github.io/zstd/zstd_manual.html#Chapter10
This is nice – but please, bring back JPEG XL too.
It's not quite as small-scale as 90's-style shareware was.
Here's the good old blog about that http://fastcompression.blogspot.com/
If compression and decompression speed are critical, lz4. Zstd for pretty much everything else.
There are edge cases where compression time doesn’t matter but decompression time does. This used to be the case for game torrents back in the old days, and UHARC was used for that to great effect. Not sure what the current king is for that purpose.
For that system, we haven't found something that beats `xz -9`.
FreeArc Next does actually use zstd as above but it also does a lot of tricks with compression, dictionaries, etc while taking much longer to process.
As an example, looking at FitGirl's COD:BO3 repack, 180GB->42.4GB entirely losslessly. Not sure how regular compression would fare on the original game, though.
repeat a few times to warm up your disk cache if needed. On mine host (with an nvme disk), zstd was about slightly better compression ratio than gzip, but took 1 second instead of 9 seconds to compress. Compare against something like lzop, which is about the same speed, but produces much worse compression.
Of course, with gzip if you have multiple cores you have the option of using pigz which bring the wall-clock time of gzip down to comparable to zstd and lzop.
(But then you should use zstd -T0 for an apples to apples comparison.)
gzip (zlib -6) [ratio=32%] [compr=35Mo/s] [dec=407Mo/s]
zstd (zstd -2) [ratio=32%] [compr=356Mo/s] [dec=1067Mo/s]
NB1: The default for zstd is -3, but the table only had -2. The difference is probably small. The range is 1-22 for zstd and 1-9 for gzip.
NB2: The default program for gzip (at least with Debian) is the executable from zlib. With my workflows, libdeflate-gzip iscompatible and noticably faster.
NB3: This benchmark is 2 years old. The latest releases of zstd are much better, see https://github.com/facebook/zstd/releases
For a high compression, according to this benchmark xz can do slightly better, if you're willing to pay a 10× penalty on decompression.
xz -9 [ratio=23%] [compr=2.6Mo/s] [dec=88Mo/s]
zstd -18 [ratio=25%] [compr=3.6Mo/s] [dec=912Mo/s]
I was comparing about ten compression algos for compressing json data. Mainly needing something reasonably fast and good compressing. zstd did well, but brotli absolutely crushed it at every metric. Of course, it's a data point of one, but it exists.
What I'm really hoping for is something as seamless as gzhttp but for zstd. https://github.com/klauspost/compress/tree/master/gzhttp
https://peazip.github.io/fast-compression-benchmark-brotli-z...
From what I gather 7zip tends to be quite a bit faster than xz, since it's been worked on/optimized quite a bit more (I didn't test this myself to verify, but I've seen several people comment on that over the last few years).
Add support for Zstandard to System.IO.Compression: https://github.com/dotnet/runtime/issues/59591
Support zstd Content-Encoding: https://github.com/dotnet/aspnetcore/issues/50643
You don’t necessarily need Rust or Node.js or Java to support zstd but you do need Traefic and nginx and haproxy to do so.
Frustratingly I use YARP, so I still need MS to implement zstd hah.
Much lighter in both the server and the client.
Even if Google is the absolute most evil company in the world, they will still make many smaller decisions every year that are just reasonable engineering. If you forget that, you end up going down a conspiracy rabbit hole and losing any ability to understand the world.