Add the allocation gate: alloc-diff and assert --max-alloc-mb - #214
Closed
jantimon wants to merge 0 commit into
Closed
Add the allocation gate: alloc-diff and assert --max-alloc-mb#214jantimon wants to merge 0 commit into
jantimon wants to merge 0 commit into
Conversation
jantimon
force-pushed
the
feat/alloc-gate
branch
from
August 2, 2026 15:20
bdc21eb to
d62f653
Compare
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.