test: deflake TestCompareDynamic_ZeroAllocHotPath#340
Conversation
|
Warning Review limit reached
More reviews will be available in 41 minutes and 36 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe hot-path allocation check in one test was rewritten to use ChangesHot-path allocation test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
aa63382 to
415134b
Compare
The zero-allocation assertion measured allocations by diffing the process-global runtime.MemStats.Mallocs counter around a 10k-iteration loop. Mallocs is process-wide, so a single allocation from a background runtime goroutine (GC assist, sysmon, the testing timer) landing inside the measurement window flipped the delta to 1 and failed the assertion. The microsecond-scale window made this rare but nonzero, producing intermittent failures under the full `go test ./...` run (observed flipping between different subtests across runs). Switch to testing.AllocsPerRun, which pins GOMAXPROCS(1) during measurement and integer-divides total mallocs by the run count. A stray sub-run-count allocation now floors to 0 instead of flaking, while a genuine per-call allocation still produces ~1.0 and fails the contract. Verified 30/30 isolated runs green and the full module suite green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Docs-exempt: test-only change, no behavioral change Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
415134b to
aabb0a8
Compare
|
Summary:
|
Summary
TestCompareDynamic_ZeroAllocHotPath(pkg/registry/file/dynamicpathdetector/tests) is flaky. It was the cause of the intermittentpr-created / testfailures (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.Mallocscounter around a 10,000-iteration loop:Mallocsis 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 to1and fails the assertion. The microsecond-scale window makes it rare but nonzero — the failure was observed flipping between different subtests across runs (literal_mismatchin CI,literal_exact_matchlocally), the signature of a flake rather than a regression.Fix
Switch to
testing.AllocsPerRun, which pinsGOMAXPROCS(1)during measurement and integer-divides total mallocs by the run count. A stray sub-runsallocation now floors to0instead 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
go test ./...suite green.🤖 Generated with Claude Code
Summary by CodeRabbit