Node.js async zstd compression was up to 23x slower — one PR fixes it

DanielLockyer · x · 2026-09-28

Developer Cherry found that Node.js's async zlib.zstdCompress() was 3-5x slower than zstdCompressSync() on the same files — up to 23x (4.5s → 0.19s).

Root cause: the sync version hands zstd the whole input in one ZSTDeend call so zstd infers the input size; the async version writes input and ends the frame in separate calls, so zstd never learns the size and sizes its tables for an unbounded stream.

Fix: PR #66358 defaults pledgedSrcSize to the input's byte length. On 162 production JS/CSS/SVG files (up to 370KB each, Linux x64), async output is now byte-identical to sync, with big speedups: level 9 from 300ms to 113ms, level 12 from 4521ms to 194ms, level 19 from 9696ms to 1474ms. Windows shows the same pattern.

Original post →

More from coding & agent

coding & agent channel →