Repository navigation
fix(server): base-branch cache keys no longer hold every loose ref path - #41661
juliusmarminge wants to merge 1 commit into
Conversation
The base-branch cache keyed entries by the raw join of every loose ref's path and stat token. In a repository with thousands of remote branches that is ~750 KB per key, and once refs move a stale key is never read again, so Effect's Cache keeps it until 2,048 keys pile up. A heap diff of a long-running server showed it growing ~9.5 MB/h, nearly all of the heap's growth. The stamp is now a SHA-256 of those tokens. The server-metrics soak now runs in a project with 3,000 loose remote refs that gains one per turn, under a web client holding VCS status, so ref-keyed caches churn as they do on a real checkout. A 12-minute soak measured 122.7 MB/h of heap growth before the fix and 15.5 MB/h after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
Closing in favor of #41740, which takes the stamp out of the base-branch cache key entirely: the key is now cwd + branch + |
The server heap grew by about 25 MB/h on a long-running desktop server. Heap snapshots taken an hour apart pinned it on
baseBranchCacheinGitVcsDriverCore, added in #40125. It grew from 11.7 MB to 21.3 MB retained, almost all of the heap's net growth.Each
BaseBranchCacheKey.inputsStampwas the rawtokens.join("\0")of every loose ref's absolute path and stat token. In the t3code repo that is about 750 KB per key. Every ref change mints a new key. Effect'sCachedrops an expired key only when that same key is read again, and a stale stamp is never read again, so old keys stay untilcapacity: 2_048evicts them. That adds up to roughly 0.75–1.5 GB.Fix
inputsStampis now a SHA-256 of those tokens, the same wayconfigHashalready is. When the stamp changes and when it stays put works exactly as before; a key just costs about 64 bytes instead of about 750 KB.Catching it next time
The
server-metrics --soakproject was a one-commit repo, and nothing in the soak subscribed to VCS status, so this cache never ran there. The soak now:12-minute soaks of this checkout (
node scripts/server-metrics.ts run --soak 12):(string)+21.2 MB(code)+4.0 MB (JIT warm-up)Testing
resolves a branch's base once while its refs and branch config are unchangedtest passes.check:changed: format, lint, knip and typecheck pass.GitVcsDriverCore.test.ts > runs background Git in its own lane so user commands never queue behind it. It fails the same way onorigin/mainwithout this change.🤖 Generated with Claude Code (Claude Opus 5.5)