Repository navigation
perf(worktrees): speed up snapshot restore and repeated creation - #146765
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, 1:56 AM ET / 05:56 UTC (Revision 2). ClawSweeper reviewWhat this changesSpeeds up managed worktree creation and snapshot restoration by reusing clean source templates, applying saved differences through Git, and caching bounded size estimates. Merge readiness✅ Ready for maintainer review The prior checkout-failure finding is addressed, and no remaining actionable defect was found. This useful optimization remains distinct from current main and the two related merged PRs. Priority: P2 Review scores
Verification
How this fits togetherManaged worktrees give agent tasks isolated Git checkouts and preserve their contents before removal. The restore service combines saved Git snapshots and provisioned-file records to recover the original branch and working files. flowchart TD
A[Restore request] --> B[Saved snapshot and file records]
B --> C[Object and disk admission]
C --> D{Reusable clean template?}
D -->|Yes| E[Clone source and apply differences]
D -->|No| F[Materialize saved snapshot]
E --> G[Restore provisioned files]
F --> G
G --> H[Original branch with saved working edits]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +241, Tests +224, Docs +2. Total +467 across 14 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep Git as the restore owner while reusing clean templates, preserving snapshot contents and branch history, and retaining conservative full-checkout fallbacks. Do we have a high-confidence way to reproduce the issue? Not applicable as a remaining correctness bug; this is a performance optimization supported by supplied paired real-service measurements and current-source inspection. Is this the best way to solve the issue? Yes. The patch extends the existing checkout and Git-worker owners, preserves stored formats and settings, and handles attribute changes and oversized inventories conservatively. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a2e647d5136f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…nclaw#146765) * perf(worktrees): speed up snapshot restore and repeated creation * fix(worktrees): bound restore inventories and defer obsolete checkouts
What Problem This Solves
Restoring a saved managed worktree rebuilt the entire source template, making even a small edit pay for another full checkout. Repeated creation also recomputed unchanged Git object sizes and index paths.
User Impact
Managed worktrees restore faster while retaining the original branch history, unstaged edits, untracked files, and provisioned files. Disk admission, missing-object checks, cancellation, and template cleanup remain enforced. No configuration or migration is required.
Why This Change Was Made
Restore reuses the original commit's source template when available and lets Git apply the snapshot differences. Otherwise Git materializes the snapshot directly, avoiding an obsolete parent checkout. If the snapshot changes
.gitattributes, Git rematerializes the full snapshot so unchanged blobs receive the correct transformations; admission includes that allocation. Oversized diff inventories use the same conservative full-snapshot fallback without raising the Git output limit.The existing Git worker retains up to 32 successful commit-size estimates, checks object availability on every request, and bypasses cached totals when replacement refs are present. Worker shutdown discards the cache. Checkout also reuses its resolved source index path and avoids repeated APFS path normalization and timestamp conversions.
Related: #146722, #146723.
Evidence