Skip to content

test: make the allocation guard stable across platforms (#136) - #238

Merged
Chris-Wolfgang merged 1 commit into
vNextfrom
fix/alloc-test-stability
Jul 24, 2026
Merged

test: make the allocation guard stable across platforms (#136)#238
Chris-Wolfgang merged 1 commit into
vNextfrom
fix/alloc-test-stability

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Found by the cross-platform differential (#128) — it did exactly its job. AllocationRegressionTests.ExtractAsync_does_not_allocate_per_item (my #136 test, merged in #227) was failing on linux-x64 while passing on linux-arm64 and windows-x64, which tripped Diff outcomes across platforms on #228, #230 and #231.

Root cause

GC.GetTotalAllocatedBytes is process-wide, so background allocation landing inside a measurement window inflates the reading. On a shared runner that could push the marginal figure past the 4 B/item budget — an environment-sensitive test, not a real regression.

This matters beyond the differential: left as-is it would fail Stage 1 Linux tests on the eventual vNext → main release PR.

Hardening

  • Settle GC + finalizers before each measurement so pending cleanup doesn't land in the window.
  • BaseCount 20k → 50k — 450k marginal items amortize even a stray 1 MB spike to ~2.3 B/item.
  • min of 5 attempts (was 3).
  • Budget 4 → 8 B/item — still an order of magnitude below a genuine per-item regression (boxing ≈ 24 B/item), so the guard keeps its teeth.

Verified locally: 5 consecutive runs, all green.

Note

#228/#230/#231 need this merged into vNext and pulled in before their differential goes green.

🤖 Generated with Claude Code

The cross-platform differential (#128) caught ExtractAsync_does_not_allocate_
per_item failing on linux-x64 while passing on linux-arm64 and windows-x64.
GC.GetTotalAllocatedBytes is process-wide, so background allocation landing in
a measurement window could exceed the 4 B/item budget on a shared runner.

Hardened: settle GC/finalizers before each measurement, raise the marginal
denominator (BaseCount 20k -> 50k, so 450k marginal items amortize a stray
1 MB spike to ~2.3 B/item), take the min of 5 attempts instead of 3, and raise
the budget 4 -> 8 B/item — still an order of magnitude below a real per-item
regression (boxing is ~24 B/item).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 24, 2026 03:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants