Node.js async zstdCompress() was 23x slower due to missing pledged input size

AI Snake Oil · rss · 2026-09-28

Cloudflare engineer Cherry found that Node.js's async zlib.zstdCompress() ran 3-5x slower than the sync version when precompressing static assets at build time.

The root cause: zstdCompressSync() hands zstd the entire input in one call so it can infer the size, while the async version writes input and ends the frame in separate calls — zstd never learns the size and sizes its tables for an unbounded stream.

His PR (#66358) defaults pledgedSrcSize to the input's byte length, making async output byte-identical to sync. Benchmarks on 162 production files (up to 370KB each, Linux x64): level 9 went 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 Infra

Infra channel →