Conversation
0b56e6f to
b4a8dbb
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66358 +/- ##
=======================================
Coverage 90.36% 90.36%
=======================================
Files 792 792
Lines 275386 275462 +76
Branches 52775 52791 +16
=======================================
+ Hits 248843 248918 +75
+ Misses 16979 16953 -26
- Partials 9564 9591 +27
🚀 New features to boost your workflow:
|
H4ad
left a comment
There was a problem hiding this comment.
I only found one benchmark that covers zstd (https://github.com/Cherry/node/blob/b4a8dbbc5a6194bd36229ffaa3bf83dcdf14f2e0/benchmark/zlib/pipe.js), might be insteresting to add another one to cover this case (at least level 12, which is fast enough to not be too long for a benchmark)
|
Added the benchmark - here's some results on my local machine for reference:
|
This comment was marked as outdated.
This comment was marked as outdated.
|
Benchmark GHA (zlib / zstd-): https://github.com/nodejs/node/actions/runs/36421711232 Results
Benchmark results:
|
zstdCompress() writes its input and ends the frame in separate calls, so zstd cannot infer the input size the way it does for zstdCompressSync(), and sizes its tables for an unbounded stream. Default pledgedSrcSize to the input's byte length. The output is now identical to zstdCompressSync() and several times faster at higher levels. An explicit pledgedSrcSize, or a string with a custom defaultEncoding, keeps the current behavior. Signed-off-by: James Ross <james@jross.me>
Signed-off-by: James Ross <james@jross.me>
4b9e7ea to
b22c547
Compare
We precompress our site's static assets at build time, and compression-webpack-plugin calls
zlib.zstdCompress()once per file. On the same files, that was 3-5x slower thanzstdCompressSync().zstdCompressSync()hands zstd the whole input in oneZSTD_e_endcall, so zstd infers the size.zstdCompress()writes the input and ends the frame in separate calls, so zstd never learns the size and sizes its tables for an unbounded stream.This defaults
pledgedSrcSizeto the input's byte length inzstdCompress(). Async output is now byte-identical tozstdCompressSync():That's 162 JS/CSS/SVG files from our production build (up to ~370 KB each), on Linux x64. Windows shows the same pattern. Single large inputs (1-64 MB) are unchanged apart from the few header bytes that record the size.
An explicit
pledgedSrcSizeis used as-is. Strings with a customdefaultEncodingaren't pledged, since their byte length depends on that encoding.