Repository navigation
Release v0.0.290
Summary
TestCompareDynamic_ZeroAllocHotPath (pkg/registry/file/dynamicpathdetector/tests) is flaky. It was the cause of the intermittent pr-created / test failures (e.g. on #339, which is unrelated — it only touches summary-storage aggregation).
Root cause
The test measured allocations by diffing the process-global runtime.MemStats.Mallocs counter around a 10,000-iteration loop:
runtime.ReadMemStats(&before)
for i := 0; i < iters; i++ { _ = CompareDynamic(...) }
runtime.ReadMemStats(&after)
require.Equal(t, uint64(0), after.Mallocs-before.Mallocs)Mallocs is process-wide, so a single allocation from a background runtime goroutine (GC assist, sysmon, the testing timer) landing inside the measurement window flips the delta to 1 and fails the assertion. The microsecond-scale window makes it rare but nonzero — the failure was observed flipping between different subtests across runs (literal_mismatch in CI, literal_exact_match locally), the signature of a flake rather than a regression.
Fix
Switch to testing.AllocsPerRun, which pins GOMAXPROCS(1) during measurement and integer-divides total mallocs by the run count. A stray sub-runs allocation now floors to 0 instead of flaking, while a genuine per-call allocation still yields ~1.0 and fails the zero-alloc contract. The contract is preserved; only the noise is removed.
Verification
- 30/30 isolated runs green (previously ~PASS/PASS/FAIL/FAIL/PASS).
- Full
go test ./...suite green.
🤖 Generated with Claude Code
Summary by CodeRabbit
- Tests
- Updated a performance-oriented test to use a more reliable allocation check.
- The zero-allocation assertion now uses per-run allocation measurement with clearer failure messaging.