Repository navigation
test(watch): burst detector on a caller-supplied clock; storm test asserts exact counts - #221
Merged
Merged
Conversation
…st asserts exact counts on a synthetic clock TestCheckoutStormCoalescesIntoOneBatch fed 500 events in 200 ms against 250 ms wall-clock windows and asserted at most 17 git calls; on a loaded CI runner the storm split into two bursts and 27 were observed (#219's ubuntu 1.26 run). The detection logic moves out of the event loop into burstDetector, whose observe, enqueue and take all take `now`, so the loop passes time.Now() and tests pass a fixed clock. The exact counts (16 per-file, then one batch of 292 files; git, topology and refresh each exactly once) are asserted on the synthetic clock, and the one test that still goes through the real loop asserts only that batching happened, with the bound derived from burstThreshold. Refs #201 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #215.
TestCheckoutStormCoalescesIntoOneBatchflaked on #219's ubuntu 1.26 run: 27 git subprocesses against the ≤17 bound, because 500 events in 200 ms against 250 ms wall-clock windows split into two bursts on a loaded runner.Change
The detection logic leaves the event loop and becomes
burstDetector(watch/burst.go):observe(now),enqueue(event, now) time.Duration,take(),pending(). None of them read the wall clock; the loop passestime.Now()and owns only the flush timer. Behaviour is unchanged;watch/events.goshrinks by the inlined closures.Tests
TestBurstDetectorOpensOnceForAStormburstThresholdevents handled per-file, then a batch of 292 (one per remaining file, last op wins), burst closed aftertake, a lone event afterwards is not batchedTestBurstDetectorCeilingClipsSettleTestHandleBurstPaysEachSharedCostOnceTestCheckoutStormIsBatchedThroughTheEventLoop4 * (burstThreshold + 1)= 68 against 500 unbatched: proves batching happened, tolerates a runner that splits the storm four waysTestFewEventsAreNotBatchedProof
go test ./watch/ -race -cpu 1 -run TestCheckoutStormCoalescesIntoOneBatch -count=30withgo test ./scanner/ -count=4running in parallel: 30/30 passed on this Mac, so the CI split did not reproduce locally; the fix is by construction, not by observation.-race -count=50clean; macOS-race -cpu 1 -count=50with the scanner suite running alongside clean (54 s); Linuxgolang:1.24in Docker-race -count=20clean.go build ./... && go test ./... && gofmt -l .clean.Not changed: the constants,
handleBurst, the seams from #215. Based on main at 0a324a7; #220 (daemon.go lifecycle) was still open and touches no line this PR edits.Refs #201
🤖 Generated with Claude Code
https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T