perf(gc): stop deleting a checkout's incremental state from blocking other builds #810
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 414 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.361
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #810"
general
weight: 0.35
jbellis
Removing a checkout's learned incremental state held the incremental cache's registrar lock for the whole recursive delete. Every mbx command that needed an incremental lease waited for it. On one host a 68,000-file checkout took 9.2 seconds to delete, and 27 of 106 checkouts took more than 2 seconds.
mbx clean, automatic collection of inactive checkouts and units, and collection of generated sources (OUT_DIRtrees) all had the same pattern.Now each of them renames the tree to a private name,
<name>.retired-<pid>-<random>, while holding the registrar, finishes its bookkeeping, releases the registrar, and only then deletes the tree. Other commands wait only for the rename. Scans skip retired names. If a process dies before deleting, the next collection deletes the leftover and counts its bytes. A retired checkout also loses its record while the registrar is held, so older mbx versions, which scan every directory in the incremental cache, ignore it rather than seed from it.This is the second of three changes that give each kind of shared cache object one owner type instead of one-off lock fixes (see #809 and #811). Retired trees are the owner type for delete-later state. No lock file is added; retired names are directory names only.
Validation. A test pauses removal after the registrar is released. At that point another process takes the registrar at once, and the same workspace can start a fresh checkout while the old files are still being deleted. That test fails on main, because the registrar is still held there. Other tests cover leftover sweeps for both the incremental and generated-source roots, and scans and seeding ignoring retired names. Hard-linked files are credited once, when their last link goes, as before.
Live run. An earlier version of this change, before the review fixes in the later commit, ran on the maintainer's host as part of a combined build from 2026-10-22T21:33Z to 2026-10-23T22:15Z, with the host off for seven hours of that: 2,128 build sessions, no cache divergences, and fewer abandoned sessions than the day before. Collections removed inactive incremental state and generated-source trees through the new rename-then-delete path, and no retired tree was left behind. The later commit's changes were tested but have not had that live run yet.
AI-assisted — Tool: Claude Code via Mjolnir; model: anthropic/claude-opus-5-5, anthropic/claude-fable-5-1, openai/gpt-6.1-sol; version: 2.1.307.
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Cache cleanup now retires stored trees before deletion and retries cleanup of leftovers, reducing the chance that undeleted data is overlooked.
Storage statistics include retired data in byte totals while excluding it from live-directory counts. Cleanup previews reflect reclaimable bytes without deleting data.
Workspace removal releases resources before deleting checkouts, so the same content can be published again sooner. If checkout removal fails, the checkout is restored.
* Unit eviction now keeps units available if retirement fails.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->