Repository navigation
Conversation
Serialize long Git maintenance passes separately from foreground checkout preparation. Keep checkout ownership only for nonwaiting pack-index invalidation and bounded pack retirement, preserving verified replacements when retirement defers. Include operation names in lease holder diagnostics.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review endedClawSweeper stopped reviewing this revision because the pull request closed. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2f4d48b30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (performance.now() >= deadline) { | ||
| break; |
There was a problem hiding this comment.
Resume deferred retirement independently of pack selection
When the retirement budget expires partway through a batch, the remaining duplicate packs can become permanently ineligible for cleanup rather than retiring on a later sweep. Subsequent passes rerun the dominant-pack filter at lines 356–362, which excludes the replacement when the remaining inputs are smaller than it. For example, consolidating two independent 64 KiB packs and retiring only the first leaves packs of 65,597 and 131,162 bytes; the next pass selects only one and therefore neither rewrites nor retires anything. Larger batches can likewise converge to a replacement plus a redundant subset, retaining substantial duplicate disk usage indefinitely. Resume the unfinished retirement independently of whether those packs qualify for another consolidation batch.
Useful? React with 👍 / 👎.
|
Landing note (maintainer review): on Team (r301, 2026-11-09 11:14–11:16Z) a startup send waited ~88 s for the project checkout lease while worktree git maintenance consolidated packs (a 354 MB promisor pack) in the shared base clone. Maintenance now serializes pack writers under its own |
…nce (openclaw#195968) * fix(worktrees): avoid checkout stalls during background pack maintenance Serialize long Git maintenance passes separately from foreground checkout preparation. Keep checkout ownership only for nonwaiting pack-index invalidation and bounded pack retirement, preserving verified replacements when retirement defers. Include operation names in lease holder diagnostics. * test(worktrees): use the exact checkout regression line allowance
What Problem This Solves
Fixes worktree preparation waiting for a shared project's entire background pack-consolidation pass. The pack writer already released the ref-mutation queue during rewriting, but an outer project checkout lease still blocked preparation.
User Impact
Foreground preparation can acquire the checkout while Git verifies and writes packs. Lease-wait diagnostics identify the holder's operation alongside its UUID. No configuration, schema migration, or operator action is required.
Why This Change Was Made
A separate maintenance lease serializes background writers. Optional pack-index invalidation and retirement take the checkout lease without waiting; busy retirement defers without suspending the repository or consuming its hourly slot. Retirement stops starting pack deletions after 250 ms, finishing the current pack's sidecars. Replaced input packs can remain as valid duplicates for a later sweep. Removal of an entire project may overlap background IO and cause a recoverable maintenance failure for that removed clone.
This completes the separation started in #191152. Base refresh and source templates are unchanged. Production code grows by 36 lines to retain background mutual exclusion, protect the short checkout mutations, and bound retirement.
Evidence
Acceptance was declared in the benchmark before measured runs: lease wait below one second while consolidation runs, unchanged HEAD and original objects, and no 20% or greater owner CPU/allocation regression. The reproducible script is
scripts/perf/worktree-checkout-lease-measure.ts; it overlays all three original owners, records source hashes, and observes a real Git consolidation launch before requesting the real checkout lease and registering a worktree.The script header supplies fixture preparation and baseline capture instructions. Run the comparison with
node --import ./scripts/tsx.mjs scripts/perf/worktree-checkout-lease-measure.ts --seed <seed> --output <new-output> --base-file <baseline-maintenance> --base-checkout-file <baseline-checkout> --base-lease-file <baseline-state-lease> --pairs 5.Five interleaved baseline/candidate pairs on a synthetic macOS/APFS fixture: 1,025 packs (1 kept base, 1,024 promisor revision packs), 62,000 files / 1.143 GB checkout, and 537 MB raw revision data. Warm filesystem caches; fresh process and clone per sample. Main-isolate allocation uses V8's cumulative allocation counter. Native Git CPU/RSS uses process receipts.
All five candidate requests acquired during consolidation; no baseline request did. Both arms launched 14 Git commands and preserved every original object without fetching. Baseline ended with two packs; bounded candidate retirement left 254–307. These are one-pass measurements, not a claim of lower total CPU to reach complete pack convergence. With five samples, p95 is the maximum. Five A/A control pairs used the same baseline code in both arms: median waits 2,667.5 / 2,669.5 ms and p95 7,089.6 / 5,140.8 ms. Host load increased during controls; no samples were discarded. One baseline control recovered from a native lease-renewal SQLite-contention warning. Smaller CPU/wall differences should not be read as a production throughput guarantee. Separate baseline/candidate CPU profiles were recorded outside the timing samples.
Registration after lease acquisition was slower under concurrent maintenance: median 24.5 → 62.3 ms. The cause is not isolated; overlap and the different pack count may both contribute. Total foreground latency improved by about 97%.
This is local owner-level proof, not a full Gateway, btrfs, or production benchmark. This owner does not read agent databases, so a padded agent database would not add exercised work.
Regression proof covers foreground preparation during rewriting, maintenance mutual exclusion, yielding retirement to foreground ownership, bounded retirement, and operation names in real contention logs. Foreground admission and owner-name regressions failed before the fix. Initial focused run: 47 passing tests, one Linux-only cleanup skip. The final five targeted cases also passed (44 s wrapper wall time, about 3 s test execution). The initial four-file run took 198 s including worker compilation. Final Codex P0–P2 autoreview against
518e8a7d43f3was scoped-clean; the allocation-only follow-up was separately reviewed. The 115 added test lines use a 110-line grant plus five lines of existing headroom.pnpm check:changed --staged --base HEAD --timedcompleted with 36 checks passing, including affected type/lint/format and database/schema guards. Two unchanged main regressions failed: historical changelog attribution rows introduced by #194364 (266a7aa0fe69), and the unusedauthorDisplayNamedashboard export introduced by #194455 (cde34f111b4d). Both failures were reproduced from exact parent518e8a7d43f3; the introducing source changes were verified. The attribution gate was already red on different rows before #194364; the current 20-row signature is new to that commit. These remain main regressions for follow-up, not passing checks. The PR does not change either owner.Prepared for review only; intentionally left unmerged.