Add the allocation gate: alloc-diff and assert --max-alloc-mb - #215
Merged
Conversation
A GC-pressure regression that allocates hard but costs little CPU passed every gate before -- cpu-diff caught the dogfood's +61% allocation only by accident, because building the array also cost CPU. A pure large-buffer churn sails through. alloc-diff <baseline> <current> --fail-on-regression gates on net allocated bytes, mirroring cpu-diff (per-package + per-function byte movers, comparability refusal, AllocDiffResult under --format json|toon). assert --max-alloc-mb <mb> gates the total against a budget. Both read a --target node --alloc recording's sidecar model; a recording with no alloc model is a loud n/a-FAIL, never a silent pass. The gate floor scales with the workload, the same shape as cpu-diff: max(--noise-floor MB, --noise-pct% of baseline), default max(1 MB, 25%). Sampled byte totals are ~15-20% directional (measured p95 15%, max 20% on a 14 MB workload), so 25% clears the noise ceiling: 0/90 identical pairs false-red, 80/80 +50% regression pairs caught. --noise-floor/--noise-pct tune each term.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A GC-pressure regression that allocates hard but costs little CPU passed every wpd gate. In the dogfood,
cpu-diffcaught a +61% allocation regression only by accident (building the array also cost CPU); a pure large-buffer / retained-churn regression sails through counts, timing, slice, and CPU gates alike.Change
Two owed surfaces, mirroring the existing CPU gate:
alloc-diff <baseline> <current> --fail-on-regressiongates on net allocated bytes (the allocation analog ofcpu-diff's net JS self-time), with per-package and per-function byte movers, a comparability refusal across an incompatible workload/lane/capture, and anAllocDiffResultunder--format json|toon.assert --max-alloc-mb <mb>gates the total sampled MB against a budget.Both read a
--target node --allocrecording's sidecar.alloc.json. A recording with no alloc model (a chrome or node-cpu capture) is a loudn/a-FAIL, never a silent pass; a run-group (no--allocmember exists) is ann/a-FAIL too.The noise floor (measured, and consistent with the cpu-diff fix)
Sampled byte totals are the directional tier (~10-20%), so the gate floor is percentage-led, the same two-term shape as
cpu-diff: net must clearmax(--noise-floor MB, --noise-pct% of the baseline), defaultmax(1 MB, 25%).[measured,
--target node --alloc, gate lock held] on a ~14 MB workload (examples/probes/allocates.mjsat--iterations 20, same module path both sides):25% sits above the 20% identical-code ceiling with margin. Verified through the built CLI's exit code:
--noise-floor/--noise-pcttune each term.Scope
src/commands/allocdiff.ts(new),src/model/query.ts(AllocDiffResult+ delta types),src/cli.ts(alloc-diff+--max-alloc-mb),src/commands/assert.ts(theallocaxis, n/a-FAIL without a model),src/index.ts+ README type table +public-typeswalker.test/unit/alloc-diff.test.mjs(6: identical, scaling floor, +50% gate, absolute-floor, knob, comparability refusal) and 2 assert alloc-axis tests (gates the sibling total; n/a-FAIL without a model).Gates: lint, format:check, build, unit (753), measurement (6), the 3 Chrome
asserte2e tests all green.Replaces #214, which was auto-closed during a botched restack after its base (#213) squash-merged; this is the same change rebased onto main with the README gating paragraph merged against #212's noise-floor text. Unit suite green on the restacked head (759 pass).