Repository navigation
fix: reduce repeated Git work during repository requests - #146273
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: blocked before merge. Reviewed September 12, 2026, 3:42 PM ET / 19:42 UTC (Revision 5). ClawSweeper reviewWhat this changesShares concurrent repository reads and moves Git output processing and worktree snapshot inventories onto bounded background workers while preserving Gateway-owned execution and cleanup. Merge readiness⛔ Blocked before merge - 3 items remain This remains useful work for the linked performance issue. The dedicated metadata worker addresses the previous contention concern, and no blocking correctness defect was found. Comparative performance evidence remains outstanding. Priority: P2 Review scores
Verification
How this fits togetherRepository requests feed branch pickers, session diffs, and PR status in the Control UI. Managed worktrees use the same Git execution infrastructure to prepare recoverable snapshots before removing checkouts. flowchart TD
A[Repository requests] --> B[Shared read cache]
B --> C[Metadata and content workers]
D[Worktree lifecycle] --> E[Maintenance worker]
C --> F[Gateway Git execution]
E --> F
F --> G[Repository results]
E --> H[Guarded snapshot publication]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1359, Tests +1178, Docs +4, Other 0. Total +2541 across 61 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single host execution owner and dedicated metadata capacity, with paired Gateway results demonstrating lower repeated work without unacceptable latency or memory regressions. Do we have a high-confidence way to reproduce the issue? Yes, for repeated work: current main independently performs Git discovery for concurrent branch requests, and the linked issue reports six Git starts per request. This review did not execute the Gateway or measure contention. Is this the best way to solve the issue? Yes, structurally: extending the existing worker pool and consolidating read ownership preserves established contracts; the remaining question is whether measured latency and memory justify the implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2f97cdbacace. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
0dfa633 to
76ec9ec
Compare
8686579 to
37ef75a
Compare
Run repository reads and snapshot inventories on reusable workers while the Gateway retains subprocesses, authority, registry writes, and cleanup. Share concurrent reads and preserve sidebar freshness without caching dirty state across completed requests. Verify snapshot HEAD atomically at publication and join cancellation through worker and subprocess teardown. Refs #146252
37ef75a to
5e22ac4
Compare
|
Merged via squash.
|
…6273) * fix: reduce repeated Git work during repository requests Run repository reads and snapshot inventories on reusable workers while the Gateway retains subprocesses, authority, registry writes, and cleanup. Share concurrent reads and preserve sidebar freshness without caching dirty state across completed requests. Verify snapshot HEAD atomically at publication and join cancellation through worker and subprocess teardown. Refs openclaw#146252 * test: track Git history fixture cleanup * refactor: share Git execution types without a worker cycle * fix: retain Git authority through accelerated checkout cleanup * fix: reserve Git metadata capacity and finish worker cutover
Closes #146252
What Problem This Solves
Repository-heavy Gateway requests repeat Git subprocesses and large path/output processing. Concurrent branch-picker, diff, and PR-sidebar reads duplicate work, while managed-worktree snapshots rebuild inventories that compete with interactive requests.
Why This Change Was Made
Reuse the existing worker pool for complete Git read and worktree inventory operations, with a dedicated metadata worker, up to two content workers, and one maintenance worker. These workers are created lazily and retire when idle. The Gateway remains the owner of subprocesses, mutation authority, registry writes, and cleanup; workers receive owned byte buffers and perform decoding, parsing, and inventory work. Batched host exchanges preserve parallel reads without competing for the pool's serial request channel.
One lifecycle-owned read cache shares in-flight branch, diff, and baseline requests. PR context and branch facts retain their established 75-second freshness. Explicit refresh replaces the generation, each subscriber receives an independent result, and cancellation only stops shared work after its last caller leaves. The final canceled caller waits for worker and subprocess teardown. Working-tree results are not retained across completed requests.
Snapshots reuse operation-local inventories and verify their pinned checkout HEAD atomically when publishing the recovery ref. Preparatory cancellation joins Git children and temporary-index cleanup. Once destructive deletion starts, it settles before cancellation returns, preserving the complete recovery snapshot. The existing allocation lease continues to protect cross-process create/remove/restore operations. Creation and restore retain the filesystem checkout owner, including Btrfs acceleration; all of its Git commands carry the same cancellation, current-authority checks, and process supervision, including queued fallback branch cleanup.
Storage keeps the existing managed-worktree rows, provisioned-file chunks, and snapshot ref format. This PR adds no schema, migration, or persistent cache. Filesystem-acceleration template storage is already part of main.
User Impact
Branch discovery normally needs two Git starts instead of six, and concurrent identical reads share that work. Large repository scans and diff parsing run off the Gateway event loop while preserving branch selection, diff results, provisioned-file rules, and worktree restoration.
Evidence
Exact-head CI passed for
5e22ac404ba66944dd927e99f57042e39334b531.Paired live Gateway comparison
Linux Testbox run: baseline
35b237db14bf619c2b58b1ac4afa9a3832b8f090versus the exact PR head, candidate treeb9a9df7854db15915efa7ec5e39e538f9d1eb9a5. Both pinned sources passed the maintainedsourcePerformancebuild profile on the same 4-vCPU AMD EPYC Linux host, Node 24.19.0, Git 2.52.0. Three runs per version used B/C/C/B/B/C order and synthetic repositories with 6,000 and 80 generated files.All six runs passed: 143 complete normalized RPC responses per run, 858 responses total, identical across versions. Only generated identities, fixture paths, and timestamps were normalized. Branch/diff freshness after external edits, all/uncommitted/commit diff scopes, main and secondary sessions, staged/unstaged/binary/provisioned content, archive/unarchive, manual remove/restore, unpushed HEAD, registry binding, and cleanup were checked. All Gateways exited cleanly; 1,207 readiness probes had zero failures.
All 30 candidate branch requests in the mixed test finished while both diffs were still pending. This verifies metadata isolation through real RPCs. The second content worker was cold: total mixed-phase wall time increased from 109.02 to 123.01 ms even though branch latency improved substantially.
The tradeoff is explicit: lazy worker startup adds cold-call latency and resident memory; moving work off the event loop does not guarantee lower total CPU or faster individual operations. Sequential diff phase time rose from 292.13 to 309.44 ms, session archive from 206.80 to 235.26 ms, and manual removal from 196.16 to 248.84 ms. The worst individual readiness probe rose from 91.03 to 119.45 ms. The measured concurrency benefit justifies these costs for this change; workers remain bounded and retire after 30 seconds idle. RSS was sampled at phase boundaries, not continuously. CPU includes Gateway worker threads and excludes Git child CPU, with 10 ms counter resolution. These are synthetic-host results, not a production latency claim.
The initial pinned-baseline full build timed out after 120 seconds rendering source
config --help, after runtime, SDK, and UI compilation passed. Its logs were preserved; the successful paired run usedsourcePerformancesymmetrically without product changes. Evidence archive SHA-256:5c41f4401f8804626b23e5e5c00ec65d4910f16aef3e7d06fb5737fae88b0a28.The automated storage warning refers to extracted size-estimation and repository-path code, not a persistence change. Existing restore contracts are exercised above; there is no new stored format to migrate. The shared cross-process allocation lease remains intentional. The Team server was not redeployed or modified.