Repository navigation
perf(worktrees): avoid a duplicate cold object census - #186294
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 SummaryThis 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR lets the full cold checkout-size scan establish object availability, reserving a missing-object census and batched hydration retry for failures. Example: Cold sizing of the complete 60,922-path repository used in the native measurements.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it removes verified duplicate work that remains on current main, preserves the existing partial-clone safeguards, and has no actionable code findings. Exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherManaged-worktree creation and snapshot restoration ask the Git worker to estimate checkout allocation; the worker returns byte totals and uses the existing admitted Git owner to hydrate missing objects. flowchart TD
A[Worktree creation or restoration] --> B[Git worker sizing owner]
B --> C[Cached or incremental estimate]
B --> D[Cold full size scan]
C --> E[Existing availability and hydration owner]
D -->|Missing objects| E
E --> D
D --> F[Byte budget for disk admission]
C --> F
Technical reviewBest possible solution: Use the existing full scan for cold availability proof while preserving admitted batched hydration and cached or incremental availability checks. Do we have a high-confidence way to reproduce the issue? Current-main source unconditionally inventories availability before the cold full size scan; the PR reports a base-failing work-count regression and native-service confirmation, which were inspected but not rerun. Is this the best way to solve the issue? The change removes redundant work at its existing owner, adds no cache or parallel sizing implementation, and retains the recovery machinery justified by earlier partial-clone incidents. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b5fa1429870a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +15, Tests +6, Other +178. Total +199 across 4 files. Added test files: 0. View PR surface stats
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 27, 2026, 4:55 PM ET / 20:55 UTC. |
Let the full size scan prove local object availability for cold estimates. Preserve cached/incremental availability checks and one admitted batch hydration retry for partial clones, with implicit transports disabled during sizing. Owner proof: CPU -37.9%, sampled allocation -51.2%, one census removed. Ten baseline and ten final-candidate native creations preserve clean checkout contents; total creation latency remains inconclusive under host I/O variation. Runtime growth is 15 lines to preserve partial-clone repair behavior.
a530a1d to
fbbc79a
Compare
Let the full size scan prove local object availability for cold estimates. Preserve cached/incremental availability checks and one admitted batch hydration retry for partial clones, with implicit transports disabled during sizing. Owner proof: CPU -37.9%, sampled allocation -51.2%, one census removed. Ten baseline and ten final-candidate native creations preserve clean checkout contents; total creation latency remains inconclusive under host I/O variation. Runtime growth is 15 lines to preserve partial-clone repair behavior.
What Problem This Solves
Cold managed-worktree creation walks every object in a complete commit to check availability, then walks the tree again to compute its disk budget. This repeats work before the checkout can become ready.
User Impact
Complete repositories avoid one full missing-object census on cold sizing. Capacity totals, isolated checkout ownership, hooks/filter exclusion, cached-fact rechecks, and partial-clone batch hydration remain unchanged. No configuration or migration is required.
Why This Change Was Made
The existing
ls-tree --format=%(objectsize)scan already fails when a required tree or blob is missing. Let that scan establish availability while computing the budget. A failed cold scan only hydrates and retries when the existing missing-object owner actually finds missing OIDs. Cached and incremental estimates retain their availability census because they do not read every target blob.Runtime +15 lines; tests +6; measurement tooling +178 (non-test diff +193: +227/−34). The runtime growth preserves the shipped partial-clone contract: one evidence-controlled retry, the existing batched fetch owner, cancellation/ref admission, and existing repair guidance. No cache or second sizing implementation is added. Partial clones can perform one failed size scan before hydration; a complete clone removes the census entirely.
Evidence
Acceptance declared in the measurement scripts: identical byte totals and checkout commit/files; one fewer cold object census; reduced owner CPU/allocation; native creation timings reported with host load, and no adverse conclusion from uncontrolled tails. The focused regression fails on the base because it observes one cold census instead of zero. The partial-clone regression retains exact fetched OIDs, unchanged refs/config, one fetch and one census, and bounds sizing to two attempts.
Owner comparison: two counterbalanced pairs, 2,000 operations per arm per pair (4,000 timing + 4,000 sampled-allocation operations per revision). Timing and allocation sampling run separately.
Final timing pairs (base→candidate): 742.35→485.09 and 776.57→458.39 µs/op. Allocation pairs: 1,611,191→784,090 and 1,609,990→787,404 B/op. Return values match in every operation. These final runs include the protocol-deny guard.
The existing workload has 10,000 files;
--coldkeeps each operation on the uncached path. Synthetic Git copies output buffers like the subprocess boundary. Native child CPU, filesystem I/O and worker queues are excluded from this owner comparison.Native comparison: completed serial batches A(5), B(5), B(10), A(5). The first B batch predates the transport-deny guard; the second B batch contains the final candidate. All fixtures contain complete objects, so neither B batch needed a transport. Fixture is a private shallow clone of OpenClaw commit
451ec41c26c67cca7d8a61b7da6b0188cf52249e, 60,922 tracked paths and a 190 MiB pack. The real service uses its state leases, worker queues, Git, source-only config and APFS templates; workers drain between samples. Source-loader startup is outside timing, worker startup is inside it. There is no setup script, ignored-file provisioning or remote fetch. Cold template creation remains included and is reported separately from warm templates.The exploratory full-history shared-clone run completed in 383.259 s, including 23.462 s missing-object census, 14.521 s size scan and 13.153 s registration. Its donor had 6,608 pack-related files totaling about 29.2 GB, and initial fixture checkout overlapped the run. These are diagnostic observations, not comparative speedup evidence.
Validation so far: cold regression red on base; final owner and worker files 27 tests passed (20 + 7), including partial clones with the no-lazy-fetch environment setting deliberately ineffective. Required import-closure files 32 passed; export collision guard, focused formatting/lint, the one targeted core typecheck, and the test-lines ratchet passed (6,286,369 / 6,286,403 on the measured base). Independent subagent review (autoreview route unavailable): no remaining actionable P0/P1/P2 findings. Hosted Codex review also completed on the original published head with no findings; ClawSweeper reported no actionable code findings. The subsequent upstream-fix rebase preserves the exact patch (stable patch ID
89b0320991186a9470ce6752266d76c1432c660d) and runtime source bytes. Review found the older-Git lazy-fetch issue; the size read now explicitly denies transports, and only the admitted hydration owner may fetch. The full service-capacity file passed 24/24 on baseline and 24/24 on final candidate. Initial CI run 40580059748 passed the selected tests, typechecks and ratchets, but failedcheck-lint-core-2on five inheritedeslint(curly)errors inui/src/pages/new-session/draft-body.browser.test.tsxandui/src/pages/chat/chat-content-column.browser.test.tsx. Both files were byte-identical to the main parente5d8882b76aea866fac2b13ef64b8cf50af21284; focused lint reproduced all five errors. Main already fixed them in8b2b0997a578, so this branch was rebased onto current main with the four-file patch unchanged. Focused lint on those files now passes. Final CI run 40592428428 completed successfully onfbbc79ada6e004e0bc69e526e89dac95f777d0ae; both requiredopenclaw/ci-gatechecks are green. Selected tests, production/test types, core and extension lint, ratchets, build artifacts, and security checks passed. This PR is intentionally left open for maintainer landing.An earlier candidate run failed the disk-headroom concurrency case (both checkouts rejected instead of one succeeding); its isolated replay passed. The full baseline and final-candidate runs then both passed without test or admission changes. Existing reservations can plausibly make both postchecks reject after the test drops capacity to the exact reserve floor, but the original rejection reasons were not captured: this remains an investigated, unattributed local failure, not a claimed fix or proven inherited failure.
This bounded duplicate-scan removal follows the requested fast proof route. No production server was contacted. The native measurement is the creation service, not a built Gateway load test; no whole-Gateway CPU/GC, event-loop or sessions.list improvement is claimed. Benchmark usage lives in each script's header; the shared perf README and test-line ceiling are unchanged.
Native creation phases and host context
Four serial batches: A1 baseline (5), B1 preliminary candidate (5), B2 final candidate (10), A2 baseline (5). Inclusive durations overlap and must not be summed. Each batch includes its first cold template; no rows were excluded. B1 predates the transport-deny guard and is supplementary; B2 supplies all ten final-candidate creations.
All 25 checkouts matched the requested commit and had clean Git status. Baseline creations each issued one missing-object census and one size scan; both candidate batches issued zero censuses and one size scan. Source-only Git suppresses hooks and filter programs; this fixture has no sparse profile, setup/dependency provisioning, remote fetch, or model turns. Mutation/source phases include state-worker admission and cold worker startup, so they do not establish lock contention by another writer.
Pooled baseline mean wall time was 75.957 s; final candidate was 78.813 s. This is inconclusive, not a speedup or adverse finding: the identical baseline batches averaged 110.665 and 41.249 s, and first-creation wall time ranged 70.964–377.597 s across batches. No controlled whole-creation tail or retained-memory claim is made. RSS/heap snapshots are not GC-aligned. The repeatable evidence is the eliminated census and the separately controlled owner CPU/allocation reduction.