Skip to content

test: measure the pool-backed allocation gates with the collector off - #103

Merged
timzifer merged 1 commit into
mainfrom
test/alloc-gate-no-gc
Nov 20, 2026
Merged

timzifer merged 1 commit into
mainfrom
test/alloc-gate-no-gc

Conversation

@timzifer

Copy link
Copy Markdown
Owner

Fixes #101.

A collection during the measured runs empties sync.Pool; the next frame refills its scratch. GOGC=5 reproduces the CI failure exactly (108 vs 98).

The gates over a render, a scene or a Build now measure through allocsWithoutCollection: runtime.GC(), then debug.SetGCPercent(-1) for the runs. Every allocation is still counted — only the between-run pool loss is gone.

Applied in: allocgate_test.go (3 helpers), three/overlay_alloc_test.go, geom/contour_alloc_test.go, backend/stilus/alloc_test.go. Not in stat/data: those gates measure caller-owned buffers, no pool.

Verified: all gates pass -count=3 at GOGC=1, 5 and 100 (previously red at 5 and 1). AGENTS.md records the rule beside the one-processor note.

Benchmarks (allocgate.awk) are left as they are: they average over many iterations and their counts have been bit-identical since onOnePGate.

https://claude.ai/code/session_015BfhXWEPyCFY4fZhg5nzsh

TestASizedLayerDoesNotAllocatePerPoint went red once on macOS, 108
allocations against 98, and was green on the rerun. GOGC=5 reproduces
the same numbers on any machine: a collection during the twenty
measured renders empties sync.Pool, and the next frame refills its
pooled scratch. That refill is a real cost, and not the one the gate
measures, which is whether a frame allocates per row.

The gates over a render, a scene or a Build — the core's three
helpers, three's overlay gate, geom's contour gate and stilus's redraw
gate — now measure through allocsWithoutCollection: runtime.GC, then
debug.SetGCPercent(-1) for the runs. Every allocation is still counted.
They pass three times over at GOGC=1, 5 and 100. AGENTS.md records the
rule beside the one-processor note.

Fixes #101

Claude-Session: https://claude.ai/code/session_015BfhXWEPyCFY4fZhg5nzsh
@timzifer
timzifer merged commit 5238c28 into main Nov 20, 2026
18 checks passed
@timzifer
timzifer deleted the test/alloc-gate-no-gc branch November 20, 2026 06:58
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.

test: the allocation gate fails when a collection empties the pool mid-measurement

1 participant