Turbopack: add zstd compression flags for NEXT_TURBOPACK_TRACING (#99808)
## Summary Adds zstd compression flags for `NEXT_TURBOPACK_TRACING`, next to `gz` and `gz-best`: - `zstd`: level 3. Recommended: about the same writer CPU as `gz`, about 25% smaller files. - `zstd-fast`: level 1, the lowest-CPU option, still smaller than `gz`. - `zstd-best`: level 19. The trace writer drops the encoder on exit (`auto_finish`), so the zstd frame is complete. If several compression flags are given, the last one wins, as before. The default stays uncompressed, and the trace format is unchanged. `zstd` was already in the dependency graph, so no new crate is compiled. `contributing/turbopack/tracing.md` documents the flags. It also notes that `zstd-best` and `gz-best` can fall behind on large traces: the data waiting to be compressed is kept in memory, and the process waits for it on exit. Stack (on top of #99765): 1. #99777: `no-memory` flag 2. #99778: Merge allocation counters into Enter/Exit rows 3. #99779: Delta-encode allocation counters, skip unchanged ones 4. #99780: Omit Exit+Enter pairs with (almost) no gap 5. #99808: **This PR**: zstd flags 6. #99809: Delta-encoded timestamps 7. #99781: Bump the trace header to `TRACEv1` 8. #99810: `upload-trace` accepts compressed traces ## Verification `next build` of `bench/heavy-npm-deps` with a release binding built from this branch: | flag | `NEXT_TURBOPACK_TRACING=1` trace | | --- | --- | | none | 23.8 MB | | `zstd-fast` | 7.2 MB | | `zstd` | 6.1 MB | | `zstd-best` | 5.1 MB | | `turbo-tasks,zstd` | 27.8 MB (raw: 155.7 MB) | - Every zstd capture passes `zstd -t`, is fully decoded by `turbo-trace-size` and loads completely in the trace server. - `1,gz,zstd` writes zstd, and `1,zstd,gz` writes gzip. <!-- NEXT_JS_LLM --> <!-- fleet 4a52842b-f1a2-43cb-9779-3655caada6a0 --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment