Decouple PASSIVE/TRUNCATE WAL checkpoint cadences - #65
Merged
Conversation
A 6-hour, 10-agent re-test of the coupled split (one ticker, TRUNCATE riding every 10th PASSIVE tick, 20s/200s effective) found PASSIVE's own median s.mu hold (3.4s, 377 calls) running higher than TRUNCATE's (2.95s, 41 calls) — backwards from what the split was for, since PASSIVE needs no exclusive lock at all. At a 20s interval there is very little real WAL content per call, so PASSIVE's hold was dominated by the same fixed per-call overhead (lock dispatch, the PRAGMA itself) that limited TRUNCATE before the split existed — paid 9x as often as necessary, because the coupled ticker forced PASSIVE's cadence to always be exactly truncateEvery/ratio. RunWALCheckpoint now runs PASSIVE and TRUNCATE on two independent tickers (passiveEvery, truncateEvery params) instead of one ticker with a tick-count ratio, so each cadence can be tuned without moving the other. PASSIVE widened to 60s (main.go) to accumulate more real backlog per call and amortize its fixed cost better; TRUNCATE's already-working ~200s cadence is left alone. Store.WALCheckpoint (the public, always-TRUNCATE entrypoint) is unchanged. TestRunWALCheckpointTruncatesOnlyPeriodically (tied to the now-removed tick-count coupling) is replaced with TestRunWALCheckpointTruncatesOnItsOwnCadence, which drives two independent cadences directly and asserts TRUNCATE fires on its own schedule regardless of how many PASSIVE ticks preceded it — verified to fail when the two tickers are collapsed back into one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PsdNZLfmAFrMX2VUtkLtmm
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.
Summary
s.muhold (3.4s, 377 calls) running higher than TRUNCATE's (2.95s, 41 calls) — backwards from what the split was for, since PASSIVE needs no exclusive lock at all.PRAGMAitself) that limited TRUNCATE before the split existed — just paid 9x as often as necessary, because the coupled ticker forced PASSIVE's cadence to always betruncateEvery/ratio.RunWALCheckpointnow runs PASSIVE and TRUNCATE on two independent tickers instead of one ticker with a tick-count ratio, so each cadence can be tuned without moving the other. PASSIVE widened to 60s to accumulate more real backlog per call; TRUNCATE's already-working ~200s cadence is left alone.Store.WALCheckpoint(the public, always-TRUNCATE entrypoint) is unchanged.Test plan
go build ./...,go vet ./...,gofmt -l .all clean (the earlier PR Shrink WALCheckpoint's interval: TRUNCATE was holding s.mu for tens of seconds #64 push missed a gofmt issue — checked locally this time)go test ./...full coordinator suite greengo test -race -short ./internal/passctrl/... ./internal/store/... ./internal/agentsrv/...cleanTestRunWALCheckpointTruncatesOnItsOwnCadence(replaces the tick-count-coupled version) verified to fail when the two tickers are collapsed back into one — 10/10 stable runs otherwise🤖 Generated with Claude Code
https://claude.ai/code/session_01PsdNZLfmAFrMX2VUtkLtmm