Repository navigation
perf(worktrees): avoid redundant checkout waits and Git queries - #146722
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. Reviewed September 13, 2026, 12:08 AM ET / 04:08 UTC. ClawSweeper reviewWhat this changesThe PR reduces redundant Git queries and APFS timestamp waiting during managed worktree creation, with regression coverage and updated documentation. Merge readiness✅ Ready for maintainer review Keep open: this remains a useful optimization absent from current main. The reviewed changes preserve checkout safeguards, and no actionable correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherManaged worktrees give agent tasks isolated Git checkouts. The checkout service validates reusable source templates, clones eligible filesystems, and lets Git validate the resulting checkout or complete a fallback. flowchart TD
A[Create or restore request] --> B[Check acceleration eligibility]
B --> C[Validate source template]
B --> F[Ordinary Git checkout]
C --> D[Clone source files]
D --> E[Prepare index after safe timestamp]
E --> G[Git validates checkout]
E --> F
F --> H[Isolated task workspace]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +37, Tests +109, Docs 0. Total +146 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep checkout preparation within the existing owner, eliminating redundant work while preserving Git validation, ACL fallback, and cancellation settlement. Do we have a high-confidence way to reproduce the issue? Yes: current main unconditionally waits for another second boundary even when clone preparation has already crossed it; supplied native before/after measurements exercise that condition. This review did not execute the runtime. Is this the best way to solve the issue? Yes: the patch removes redundant work in the existing checkout owner while retaining conservative validation and fallback, without adding configuration or competing implementations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 70fe5d707523. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Related: #146401 and #146586.
What Problem This Solves
Cached worktree creation runs redundant Git queries and can add another second of APFS timestamp waiting after the clone is already old enough for safe index validation.
User Impact
APFS checkouts avoid the redundant timestamp delay. Accelerated worktree creation uses fewer Git subprocesses, without new configuration or changes to ACL eligibility, cancellation, or edit detection.
Why This Change Was Made
Anchor the timestamp deadline at completion of the admitted clone, count subsequent Git metadata preparation toward it, and retain the per-file ctime and clone-provenance checks. Read template cleanliness and HEAD together, read destination HEAD and index path together, and overlap the two attribute-path probes while joining both before returning or throwing.
Git still owns registration, index validation, and fallback checkout. NUL-delimited status records and first-line-only HEAD parsing preserve unusual filename/path handling. This changes neither the cloning backend nor dependency versions.
Evidence
clone timestamp boundary already passed, then passed with the repair. Existing same-size edits with restored mtimes remain detectable.Captured timing results
Native APFS index preparation, after Git preparation has already crossed the completed clone's timestamp boundary, six trials per variant with 128 files:
Both variants used the real native clone and Git status validation. The measurement starts after the timestamp-boundary precondition and includes the real index translation/write; it is not a whole-checkout speedup claim.
For a 2,049-file, 40 MiB fixture, twelve paired warm-create samples per variant started at matching positions within the wall-clock second, with alternating variant order:
The loaded host and second-boundary timing made complete-create results mixed; these samples do not establish a general end-to-end speedup. The deterministic improvements are two fewer Git processes and elimination of the redundant completed-boundary wait. All measured checkouts had clean Git status and correct payload sizes.