Repository navigation
chore(test): reduce large-index GC startup overhead - #155928
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 22, 2026, 6:38 PM ET / 22:38 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR precompiles the large-index worktree cleanup test’s Node subprocess and nested workers to reduce startup overhead without changing product behavior. Merge readiness✅ Ready for maintainer review The optimization remains useful on current main, preserves the regression’s meaningful checks, and has no actionable correctness findings. The supplied performance evidence appropriately limits its claim to the large-index case. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s worktree cleanup tests exercise removal and recovery against real Git repositories. The test runner prepares subprocess code before a bounded Node child runs cleanup, then checks that saved edits and deletions restore correctly. flowchart TD
A[Large Git index fixture] --> B[Test runner]
B --> C[Prepared subprocess build]
C --> D[Node main-thread cleanup]
D --> E[Git worker and repository]
E --> F[Removal and snapshot results]
F --> G[Restore and verify edits]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +19, Other +4. Total +23 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the real Git recovery regression while preparing its child runtime through the existing test-runner owner. Do we have a high-confidence way to reproduce the issue? Not applicable as a product bug: this is test-performance work supported by source-bound before/after measurements. The historical CI timeout remains unexplained, and this review did not execute tests. Is this the best way to solve the issue? Yes. Reusing the existing preparation owner removes source-loading work from the child’s deadline while preserving the real Node/Git boundary and recovery assertions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ed336efe0537. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
fcfc835 to
7099bd6
Compare
|
Merged via squash.
|
F107: main run 35785419091, job 106941944643 exhausted the large-index GC fixture's 60-second child deadline. A two-CPU Testbox with CPU pressure reproduced the failure during snapshot preparation. Every traced Git command exited; the slowest took 0.43 seconds. Snapshot preparation awaited one lstat per changed path, including 180,000 missing tracked files. Read metadata in bounded batches of 64, joining all reads before preserving the first path-ordered error. Keep missing-path classification, snapshot capacity accounting, and authority guards intact. Retain the prepared Node child fixture landed concurrently in #155928. That change removes cold source startup; this change removes the serial metadata bottleneck in the production snapshot owner. No deadlines, assertions, snapshot retention, or public contracts change.
* commit '7d7f977ccfc1ac177526232e4f4960febd010015': (91 commits) test: avoid unused target setup in package profile fixtures (#155972) fix(worktrees): batch snapshot metadata reads test(plugin-state): distinguish borrowed and foreign lifecycle owners refactor(agents): share external harness session and attempt machinery (#152181) chore(i18n): refresh native locales (#156006) chore(test): retain Doctor fixture settlement diagnostics (#155944) perf(codex): reuse unchanged inference request bytes (#155987) perf(test): prepare snapshot ownership subprocess imports (#155973) perf(test): consolidate channel registry coverage (#155014) fix(runtime): preserve Node worker dependencies and cleanup diagnostics (#155292) perf(test): prepare worktree GC child runtime (#155928) fix(ui): open browser cards after delayed panel renders (#153253) fix(update): retain the running updater by hard link instead of copying the package (#155977) feat(decisions): add explicit evaluation and Labs opt-in foundation (#155134) fix(state): preserve lifecycle custody across worker dispatch improve: reuse shared tooling fixtures and defer legacy updater proof (#155731) improve(ui): reduce real-Gateway test preparation (#155979) perf(state): move session RPC SQL off the Gateway main thread (#155740) docs(freebsd): explain native Codex runtime limits (#155980) fix(qa): count Code Mode nested tool activity as transcript tool evidence (#155976) ...
F107: main run 35785419091, job 106941944643 exhausted the large-index GC fixture's 60-second child deadline. A two-CPU Testbox with CPU pressure reproduced the failure during snapshot preparation. Every traced Git command exited; the slowest took 0.43 seconds. Snapshot preparation awaited one lstat per changed path, including 180,000 missing tracked files. Read metadata in bounded batches of 64, joining all reads before preserving the first path-ordered error. Keep missing-path classification, snapshot capacity accounting, and authority guards intact. Retain the prepared Node child fixture landed concurrently in openclaw#155928. That change removes cold source startup; this change removes the serial metadata bottleneck in the production snapshot owner. No deadlines, assertions, snapshot retention, or public contracts change.
What Problem This Solves
The large-index worktree GC regression spends part of its bounded child-process run loading TypeScript and source workers.
User Impact
No product behavior changes. The large-index case is faster in both measured pairs, with the same real Git input and recovery assertions. Whole-command benefit is inconclusive, and the cause of the historical CI timeout remains unexplained.
Why This Change Was Made
The test now uses the existing prepared-subprocess owner, as the Code Mode retention fixtures do. A thin fixture runs GC in a real Node main-thread process and resolves its nested Git worker from the same prepared generation. Source execution retains the existing resolver fallback.
The 180,000-entry index, 60-second managed deadline, strict process-tree exit, local-edit/deletion restoration, and all 37 cases remain. Production GC and inventory code are unchanged. The real main-thread boundary matters: #138066 originally caught a stack overflow that Vitest worker threads could miss.
Evidence
Proof used configured Blacksmith Testbox, pinned to
f9c524daa03e5febd2bc3fb01c6f3cb7387798bdplus the exact five-file candidate treefa7b62db5bfee47df970b8c44774ae722bd8d235.pnpm test src/agents/worktrees/service.gc.test.ts --maxWorkers=1.pnpm buildpassed in 314.001 s. Independent P2 review found no actionable issues.RangeErrorthrough both routes. This is a translated primitive control, not a replay of the entire historical checkout.Comparison lease · Standalone, siblings, gate and build lease · Original-order qualification lease. These identify the Testbox leases; the manual command receipts and downloaded archives were verified separately. All owned leases are stopped. Published-head CI is recorded below.
Current-main integration
The unchanged five-file optimization was refreshed onto
85a481530c44cebb0736f9bf00a9da18cd786fcf, including the canonical wrapper-inventory repair3a4bbc6882a. Its stable patch ID remains1772e9ca8a3d818a9c46980dc62576008539a2de; current manual proof covers candidate tree81cc43e79550069ad674df7379d851a5440d586d.The first published head
fcfc835bfe733b5b2642ab86d990e0a368f42ab7ran as merge914cd06d6a1c830ac92659c99f52a4ba46c9f7e8ontof0d26603a5c1210dab73e4362b017eccdd585931. Its GC shard passed all 37 cases: 37.651 s summed reported case durations, including 8.837 s for the large-index whole case. CI did not emit a complete file wall time. The overall run failed in five tooling jobs: a prior main refactor,43d85e5f9ac3, had omitted the extracted reader-context and spawn-diagnostics files from the wrapper inventory. The canonical two-row repair restores those dependencies; it is inherited from main, outside this optimization's five-file delta.Current integration used configured Blacksmith Testbox. Its proof passed:
Published head
7099bd69ee5bdd3037c15ad8e166542aaf0f0faenow has green CI, including the integration build. It tested merge3a9cb24efbee3feaabc32c1682c46fe2165867beontobc635fc9400da428818ceb9e736de26336ee8f96. The GC shard passed all 37 cases: 41.133 s summed reported case durations, including 11.002 s for the large-index whole case. CI did not emit a complete-file wall time. These are absolute costs on the published merge, not a new before/after comparison.These are current-source absolute costs, not another before/after benchmark. The earlier ABBA, 20 standalone runs and three original-order replays below retain their original source bindings and qualifications.
Measured cost
The untraced comparison ran all 37 cases on four CPUs/16.56 GB, using the normal runner and cache policy:
The target case improved 47.81% before the interruption and 45.09% afterward. The comparison was interrupted between B1 and B2 for 22m14.861s, measured from B1's test-file end to B2's command start; the original B1 command-end timestamp was not recorded. Preparation and unrelated case costs drifted substantially. These measurements do not establish a whole-file, full-suite, or memory saving; overlapping phases are not additive.
The three qualification replays took 449.363/421.280/437.896 s, with large-index whole-case times of 15.067/16.978/16.692 s. These are absolute costs, not new before/after comparisons. The file needs real processes and Git recovery to exercise the main-thread stack and filesystem contracts; reducing the index or substituting mocked recovery would lose that proof.
Source binding and interrupted-proof qualifications
The first comparison stopped after B1 because its proof driver incorrectly required identical emitted bytes across separate generations. Full compiler input maps were identical; the fixture differed only in its generated service-chunk import. The compiler embeds the output directory in external URLs, so those names are directory-bound. The corrected check verifies each generation against its own manifest; only the unrun B2/A2 cells resumed. The original assertion failure, executed-route traces, negative controls and timing gap remain preserved. Transitive service-chunk bytes were no longer available after normal generation disposal. No per-arm or per-replay loaded-byte attestation is claimed.
One later standalone command, B03, completed while local disk exhaustion interrupted its control-process capture. Read-only recovery verified all 37 passing cases, command exit 0, all 618 source hashes, all 10,585 compiler-input hashes, emitted-output manifest checks and native disposal verification. It was counted once, with a separately recorded post-interruption source snapshot; the original controller result/source-after files are missing. B04–B20 then completed with normal per-phase receipts. Pre-test transport, idle-expiry and ownership-transfer refusals are retained separately and receive no test credit.
The final 281-file standalone/gate/build archive and separate 25-file original-order archive were hash-verified. Historical f9 measurements and manual checks retain their pinned source. Newer main registrations for benchmark/process fixtures and the Git worker's workspace-input native-section handling were not silently included in that historical proof; current 85a integration is recorded separately above. The canonical main unused-export repair is
1619aff4781603cb998646f5ac8068603dbd3e20; it is unrelated to this five-file delta.The current-main proof also stopped after three successful commands because its completion-label guard checked
shard_name; the native runner emitstiming_keywhen present. The successful command exit, test results, native completion marker, all 849 source hashes and original archive were reconciled. Only that proof guard was corrected; the completed commands were retained and only four unrun tooling groups plus the changed gate continued. The current source has six additional cases across the same 196 selected files: three ownership-table cases from newer main's Gateway registrations, and three newly added CI workflow-guard cases. This was a proof-harness interruption, not a test failure or retry.