Skip to content

test(telemetry): assert commit cost on allocation, not peak heap - #257

Merged
vishr merged 2 commits into
mainfrom
test/stabilize-commit-peak-heap
Sep 20, 2026
Merged

vishr merged 2 commits into
mainfrom
test/stabilize-commit-peak-heap

Conversation

@vishr

@vishr vishr commented Sep 20, 2026

Copy link
Copy Markdown
Member

Fixes the flaky gate introduced in #255. main is currently red.

What went wrong

The commit-memory test failed CI at ratio 3.83x against a 3.75 limit, for code that measured 2.79x–3.49x locally. I set that threshold from local runs on one machine and it did not survive a different one.

Worse, when I stabilised the sampling by taking the minimum across several commits, I found the threshold was never sound in the first place:

Encoding peak heap, min-of-3
dictionary (the regression) 3.21x – 3.56x
plain (current) 1.45x – 2.52x

A limit of 4.0 — which is where I would have landed to stop the flake — passes the regression the test exists to catch. The test would have looked green and gated nothing.

Fix

Assert on total bytes allocated instead of peak live heap.

Encoding allocated
dictionary 10.68x – 10.90x
plain 4.40x – 5.69x

No overlap, and the dictionary figure varies by about 2% across runs. Peak heap carries whatever slack the collector happened to be holding when the sampler looked, which varies with GOMAXPROCS and machine speed; total allocation does not, and it answers the question the test is actually asking — how many copies does one commit make.

Limit set to 7.0, in the middle of the gap, and verified in both directions: restoring the dictionary tags fails it at 10.6x.

Peak heap is still sampled and logged, because it is what the kernel kills on, and it is now reported as the minimum across three commits so the number is comparable between runs.

Note on method

I should have validated the original gate against the regression before merging #255 rather than only against the fix. A threshold that only ever passes proves nothing. This PR verifies both directions, and that check is cheap enough that it should be the habit.

just check passes.

The commit-memory gate added in #255 is flaky and its threshold does not
separate the two encodings. It failed CI at 3.83x against a 3.75 limit for
code that measured 2.79x-3.49x locally, turning main red.

Peak live heap was the wrong signal. It carries whatever slack the
collector happened to be holding when the sampler looked, which varies
with GOMAXPROCS and machine speed, and the two encodings' peak-heap
distributions overlap: dictionary encoding measured 3.21x-3.56x and plain
1.45x-2.52x once the sampling was averaged over several commits. A
threshold between those is a coin flip, and the 4.0 I first reached for
would have passed the very regression the test exists to catch.

Total bytes allocated does separate them, and barely varies: 10.68x-10.90x
with dictionary encoding against 4.40x-5.69x without. It also answers the
question the test is actually asking -- how many copies does one commit
make -- rather than how much the collector was holding at one instant. The
limit moves to 7.0, in the middle of that gap, and is verified in both
directions: restoring the dictionary tags fails it at 10.6x.

Peak heap is still measured and logged, because it is what the kernel
kills on, and the figure is now the minimum across three commits so the
log is comparable between runs.
The race detector instruments every allocation, which inflated total
allocation from roughly 5x payload to 33x on unchanged code and failed the
race target in CI. Peak heap is distorted the same way. These figures are
only meaningful in an uninstrumented build, so the file is excluded from
-race rather than given a second, meaningless threshold.
@vishr
vishr merged commit b7655aa into main Sep 20, 2026
8 checks passed
@vishr
vishr deleted the test/stabilize-commit-peak-heap branch September 20, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant