tasks/track_memory_allocations/README.md
Tracks the number of heap allocations made by
rolldown_sourcemap's per-chunk machinery —
SourceJoiner::join (chunk assembly + sourcemap merge) and collapse_sourcemaps
(the minify / transform chains) — for a fixed set of scenarios, and records the
counts in a committed snapshot (allocs.snap).
CI re-runs the tool and fails if the snapshot changes, so any allocation regression (or improvement) on this codegen hot path shows up as a reviewable diff instead of silently slipping in.
Scenarios are driven by real sourcemaps produced by oxc codegen, generated
outside the measured window so each count reflects only the rolldown_sourcemap
operation.
just allocs # or: cargo allocs
This regenerates allocs.snap. Commit the result if the change is expected
(an intentional improvement), otherwise investigate the regression.
Allocs vs Reallocs: Allocs counts fresh allocations; Reallocs
counts in-place grows (realloc). Pre-sizing a Vec/String moves counts out
of Reallocs — an improvement, not a regression.join / collapse_sourcemaps. See measure in
src/main.rs.just allocs should match; if it ever differs on your OS/arch, trust CI.rolldown_sourcemap (and its
transitive oxc / oxc_sourcemap) internals, so a bump that changes allocation
behaviour will legitimately move the snapshot — run just allocs and review the
delta as expected churn.