next.js
0e324e12 - Turbopack: delta-encode trace allocation counters and skip unchanged ones (#99779)

Commit
34 days ago
Turbopack: delta-encode trace allocation counters and skip unchanged ones (#99779) ## Summary The allocation counters on `Enter`/`Exit` rows are now the **delta** since the previous report of the same thread, not cumulative per-thread totals. When nothing was (de)allocated, the delta is omitted (`None`). Cumulative counters are large numbers, so their varints take many bytes. Deltas are mostly small or zero: in a typical trace, half of all reports had an unchanged counter. - The writer keeps the last reported counters per thread. The first report of a thread only sets the baseline (`None`). That state also stores the thread id, because `thread_local` slots are reused after a thread exits, so a new thread never diffs against an old thread's counters. - The trace server attributes the delta directly, with no per-thread cumulative state. Stack (on top of #99765): 1. #99777: `no-memory` flag 2. #99778: Merge allocation counters into Enter/Exit rows 3. #99779: **This PR**: delta-encode allocation counters, skip unchanged ones 4. #99780: Omit Exit+Enter pairs with (almost) no gap 5. #99781: Bump the trace header to `TRACEv1` ## Measurements `next build` of `bench/heavy-npm-deps`, release native binding built from source: | | trace size | | --- | --- | | original | 68.2 MiB | | PR 2 | 58.8 MiB | | this PR | 31.6 MiB | ## Verification - Unit tests in `raw_trace.rs` for deltas, omitted zero deltas, the per-thread baseline and a reused thread slot - Captured a trace with a locally built binding and loaded it in the trace server <!-- 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>
Author
Parents
Loading