by twotwotwo · 8y ago · 0 comments
On Twitter a designer of Brotli raised the question of whether there should be a standardized limit on RAM required to decode in the HTTP Content-Encoding context, since zstd supports huge window sizes (GBs). I don't feel strongly--clients can refuse to handle responses that take too much RAM to decode, servers have an incentive to serve up things their clients can handle, and there tend to be sharply diminishing returns to increasing window size--but I can imagine a limit in the MBs being a reasonable compromise between allowing high compression and not breaking on phones with a couple hundred MB RAM.
> In order to protect the decoder from unreasonable memory requirements, a decoder is allowed to reject a compressed frame that requests a memory size beyond the decoder's authorized range.
> For broader compatibility, decoders are recommended to support memory sizes of at least 8 MB. This is only a recommendation; each decoder is free to support higher or lower limits, depending on local limitations.
As a corollary, and in the absence of an explicit negotiation process between client and server, servers should probably avoid using a window larger than 8 MB.
(or section 6.2 of the linked RFC)
Mozilla has a bug here (about Transfer-Encoding): https://bugzilla.mozilla.org/show_bug.cgi?id=1477516
Couldn't find any mentioning zstd in the public Chrome, WebKit, or MS Edge issue trackers.
[1] https://github.com/facebook/hhvm/commit/d830ac5b335cea8433ab...
So it specifies what Content-Type header your browser should use for a .zst file, but doesn't represent a plan to let your HTML, JS, CSS etc. be delivered compressed using Zstd and transparently decompressed by the browser, as is possible with the gzip and br Content-Encodings.
git clone https://github.com/faragon/libsrt
make
./enc -ezh <hugefile >output.zh
For decompress:
./enc -dz <output.zh >hugefile.again