Zstandard support #69
Replies: 8 comments 8 replies
-
I'm well aware of the Zstandard situation on the web. I've actually already been trying to build a Zstandard encoder/decoder in JS, but unfortunately it's a massive undertaking not only due to the higher complexity of the algorithm but also because JS simply has a speed limit. The reason If you are looking for decent Zstd bindings, check out these. 183kB minzipped, which isn't terrible, and there's no issue with bad compression. (By the way, the author also wrote the best Zlib WASM bindings I've seen, which are still typically slower than Regardless, I'm still going to work on a Zstandard encoder and decoder, but it won't be part of |
Beta Was this translation helpful? Give feedback.
-
Awesome! Thanks for the thorough answer and good news. |
Beta Was this translation helpful? Give feedback.
-
@101arrowz Could you guess at how long that will take? Like are we talking about days, weeks, months? |
Beta Was this translation helpful? Give feedback.
-
Maybe 3-6 weeks, assuming nothing comes up. Since I don't have a personal need for Zstandard, I probably won't be able to stick to an exact schedule, but that's my estimation. In the meantime I recommend the Zstandard bindings I linked; they're pretty fast and are a good compromise if Zstandard compresses that much better than GZIP. |
Beta Was this translation helpful? Give feedback.
-
In the meantime I've made a ~27kb decompressor-only port of zstd v1.5 to wasm that should be as fast as the one you linked (it's compiled with -O3 and it's much lighter to load actually), I'm not too sure about reliability though, but thinking about this I have the luxury of only needing to decompress some files I'm compressing myself, so I can just check if it's able to decompress those files before shipping them. |
Beta Was this translation helpful? Give feedback.
-
I've created a working Zstandard decompressor, but it has subpar performance (7x slower than WebAssembly). I'll try to improve performance a bit before publishing. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately my optimization efforts haven't yielded meaningful improvements. Performance varies from 2x to 5x slower than WASM (though the bundle size could make up for this; it's 7kB minified). I'll add support for dictionaries before publishing (should be pretty soon now). |
Beta Was this translation helpful? Give feedback.
-
How to implement ZSTD method compression, looking forward to reply. @fabiospampinato @101arrowz |
Beta Was this translation helpful? Give feedback.
-
What can't you do right now?
Zstandard compresses amazingly well, for my use case up to 4x better than what I can get from gzip, and it decompresses perhaps even more amazingly well.
For my use case I kinda have to use Zstandard given its characteristics, but there doesn't seem to be a great port of Zstandard for the browser, plus I'm already using
fflate
which I find well done and pretty fast, but it just doesn't support Zstandard.An optimal solution
Optimally
fflate
would add support for compressing and decompressing (although just decompressing would be enough for me, and I'd guess for most other people too) using Zstandard with a high quality and fast implementation.(How) is this done by other libraries?
node-zstd
: it uses native bindings, a no-no for the web.node-zstandard
: it just spawns zstd as a child process.zstd-codec
: it's a 1 year out of date emscripten compiled version of zstd, which weighs almost 1MB min+gzipped and can't be tree-shaken.zstddec
: this seems the best port to webassembly, it only supports decoding and weighs ~17kb, but it has the following pretty concerning warning in its readme:Basically there currently isn't a great option for decoding zstd files on the web and I'd love to see one from
fflate
.Beta Was this translation helpful? Give feedback.
All reactions