Turbopack: merge allocation counters into trace Enter/Exit rows (#99778)
## Summary Removes the separate `AllocationCounters` (and the unused `Allocation`) trace rows. Their data is attached to the `Enter`/`Exit` rows as `allocations: Option<Allocations>` instead. Before, the writer emitted one `AllocationCounters` row before every Enter and Exit. Each carried its own tag, timestamp and thread id. Those rows were **66%** of a typical trace. Since the counters are always paired with an Enter/Exit, the duplicated tag, timestamp and thread id can go. - `TraceRow::Enter`/`Exit` get an `allocations` field (`None` when memory isn't tracked). The new `Allocations` struct is shared by writer and readers. - Trace server: the counters on Enter/Exit go through the same diff-and-attribute logic as before. The span on top of the thread's stack before the row is applied gets the allocations: for Enter, the previously running span; for Exit, the exited span. - `turbo-trace-size`: the `AllocationCounters`/`Allocation` row kinds are removed. Enter/Exit now have an `allocations` component. This is an incompatible format change. The `TRACEv1` header bump comes last in the stack (PR 5), and older traces are then rejected with an error. The stack is meant to land together. Stack (on top of #99765): 1. #99777: `no-memory` flag 2. #99778: **This PR**: 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. #99781: Bump the trace header to `TRACEv1` ## Measurements `next build` of `bench/heavy-npm-deps`, release native binding built from source: | | trace size | rows | | --- | --- | --- | | before (PR 1) | 68.2 MiB | 4.65 M | | this PR | 58.8 MiB | 2.37 M | ## Verification - New trace server test checks allocation attribution for Enter/Exit rows through `TurbopackFormat` - 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>
Showing
This diff is collapsed.
Please
register
or
sign in
to comment