Repository navigation
perf(worktrees): publish reserved checkouts without allocation waits - #169178
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR removes redundant global allocation admission when publishing a reserved worktree and adds preparation timing diagnostics. Example: A completed checkout publishes while another creator holds the global allocation lease for two seconds.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR removes a real publication bottleneck still present on main while preserving checkout custody and atomic slot accounting. No introduced correctness defect was found; exact-head CI has an unattributed terminal UI failure and cancelled checks. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherManagedWorktreeService turns session or CLI creation requests into Git checkouts and registry records; allocation reserves capacity, checkout custody owns preparation, and the SQLite worker atomically exchanges pending slots for live records. flowchart TD
A[Creation request] --> B[Checkout custody]
B --> C[Global slot reservation]
C --> D[Git checkout and setup]
D --> E[Source and disk admission]
E --> F[Atomic worker publication]
F --> G[Ready worktree]
Technical reviewBest possible solution: Publish reserved checkouts through the existing worker under retained checkout custody, preserving source authority, disk admission, and atomic slot accounting. Do we have a high-confidence way to reproduce the issue? Current main visibly reacquires the global allocation lease after materialization, so an unrelated holder delays publication; the PR reports a controlled before/after reproduction through the real service. Is this the best way to solve the issue? The change fixes the owning publication path directly: pending-to-live publication preserves capacity, and the existing transaction already checks checkout custody and pending identity. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 23ad242958a4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +75, Tests +57, Docs +6. Total +138 across 11 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 11, 2026, 11:17 AM ET / 15:17 UTC. |
|
Landed as f8381bf using the maintainer-authorized inherited-failure exception. Exact-head CI 38150167763 failed Scoped proof passed: 48 focused tests; all 55 worktree sibling files covered (49 passed, six platform skips); core and dependent test typechecks; independent review with no actionable findings. The separate unused-export audit reproduced the same 61 entries on unchanged baseline. No CI rerun or update-branch was used to chase green. The native merge helper stopped before dispatch because its installed trusted-tooling dependency did not match the required frozen version. The authorized REST fallback pinned the reviewed 860acf0 head; merge state and main ancestry were verified afterward. |
What Problem This Solves
Completed managed checkouts can wait behind unrelated worktree allocation before becoming usable, and existing preparation logs hide most of that wait.
User Impact
An already reserved checkout publishes without reacquiring global allocation. Its retained checkout lease, source authority, disk admission, and atomic pending-to-live transaction remain enforced. No new setting, migration, or stored-shape change.
Why This Change Was Made
Publication exchanges one pending slot for one live record; capacity does not change. The writer already verifies pending identity and retained checkout custody. The second global admission and its recovery pass therefore add contention without protecting another invariant.
The existing diagnostic record now attributes allocation/mutation/capacity waits, repository/source preparation, reservation, base refresh/hydration/fast-forward/share wait, registration, disk admission, provisioning, publication, index refresh, and custody release. Nested phase times remain inclusive;
unattributedMsmeasures uncovered wall time without subtracting overlapping phases twice.Production LOC: +75 net, required by the requested diagnostic fields and coverage accounting. The performance change deletes the redundant admission path; it adds no cache, alternate path, or compatibility shim.
Related: #169070. The historical comparison does not establish that shared refresh caused the reported long remainder. Twenty “fetch succeeded” messages are per-worktree reporting: all three historical bursts performed one actual fetch. Local-default fast-forward ran twenty times before that change and once afterward.
Evidence
Controlled contention through
ManagedWorktreeService.createWithOutcome: publication 2,167.138 ms → 6.614 ms while another real allocation lease was held for two seconds. The candidate published while that holder was still active. This used a synthetic repository setup script gated by FIFOs and the actual lease/registry path, with no mocked Git.The permanent regression fails on the original code with “Publication waited for the unrelated allocation holder” and passes after the change. The existing refusal test now revokes the retained checkout lease, preserving its authority check instead of requiring the removed allocation lease.
Twenty-create full-repository bursts all completed successfully. The first pair measured median 16.031 → 13.2645 s, but reverse order measured 12.1255 s baseline versus 11.858 s candidate (2.2%), with slightly worse candidate tail. Do not read the first pair as a universal 20% throughput improvement. The robust benefit is eliminating publication's dependency on unrelated allocation; global allocation acquisitions fall from 40 to 20 per twenty-create burst.
Conditions: Linux Blacksmith Testbox,
openclaw-check, 16 vCPU, Node 24.19, full blob:none OpenClaw source at38f456226f626dd3868c2a4e754e75bf37b59e68, same-process warmup, synthetic state, and pinned local origin. Setup, ignored-file provisioning, and acceleration were disabled for full-tree timing. The reported 21-second production remainder was not reproduced; no production host was accessed. The initial shared-rig attempt hit disk-reserve pressure and was discarded.The tested patch was rebased without changes onto main
289d859c2babddd9f5aee9dda96fbb94c5107f70; final candidate860acf01abf7e020019ca9061e64dd48f73c2e2dhas the same stable patch ID.Remote proof:
blacksmith-testbox/tbx_01m4nm1zf7b2nnwxr7fnhw5k6r: original-code regression failure, then 48 focused tests passed; first full20 baseline/candidate pair;node scripts/check-changed.mjs --base 3a697ca4265b8302dca2b0191748a231c7c16432passed every check except inherited dead exports (26m22s).blacksmith-testbox/tbx_01m4nnahysgwrfxrjxcf2x2v7a: all three historical full20 bursts, reverse pair, controlled real-lease measurement, and all 55 remaining worktree sibling files covered. Two initial fixture failures were caused by placing TMPDIR inside a Git checkout; both passed with external TMPDIR. The obsolete allocation-authority assertion was corrected and its file passed.3a697ca4265b8302dca2b0191748a231c7c16432, with the exact same 61 reported entries, all outside the touched files. Examples include UIrenderProviderFallbackIcon/renderDocsLinkand subagentloadSubagentMaintenanceCandidatesInDatabase. This is recorded as inherited, not a passing gate.Single-worker test costs:
pnpm test src/agents/worktrees/preparation-timing.test.ts --maxWorkers=12.71 s;pnpm test src/agents/worktrees/service.pending-slots.test.ts --maxWorkers=128.50 s; repairedregistry-read.test.ts76.74 s. The latter is the existing real SQLite worker publication/lifecycle suite; the change replaces one authority target and introduces no extra boot or timer.Full first-pair phase table (baseline → candidate)
Values are median / p95 / maximum in milliseconds; phases are inclusive and must not be added. p95 is nearest-rank over20 samples.
Unentered phases are shown as zero by the comparison; lease/source release instrumentation was added afterward and is absent from the baseline. Shared refresh/hydration/fast-forward occur once, so their maxima show that operation rather than a median over zero-filled borrowers. Times are inclusive and cannot be summed.
Historical phase table on the same host and source
The historical
allocation.waitincludes initial checkout custody and both global allocation acquisitions.finalPublicationis the derived interval after materialization/setup through return, including global reacquisition. The oldest/intermediate/current code ran in that comparison's documented current → oldest → intermediate order; this is diagnosis, not a causal throughput claim.Full reverse-order phase table
CI disposition
Exact-head CI 38150167763 stopped on
checks-ui-e2e (1/2):chat-panel-layout.e2e.test.ts:379, “preserves live content and saved geometry across main, dock, focus, and narrow layouts,” times out after 30 seconds waiting for the terminal canvas to become visible. The same test, line, locator, and hidden-canvas failure already occur in scheduled main CI 38147604740, commit6233a19ea75bbcd079ec4dbe4660bfef9b9321ed. The actual tested merge567fc8fcf1c10bc4ceaaa771c1ac02691985a7a3contains no UI delta from its main parent698cac4c78b806d5db143008e4b83fd588a33583.The aggregate CI gate failed downstream and fail-fast cancelled other jobs; those cancellations are not passing proof. Landing uses the maintainer-authorized inherited-failure exception, backed by the focused, sibling, typecheck, and independent-review evidence above. No CI rerun or update-branch was requested.