Repository navigation
perf(worktrees): bound Git pack maintenance to verified batches - #182204
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. |
984ed9f to
4fd450f
Compare
|
Codex review: blocked before merge. What this changesThis PR replaces repository-wide multi-pack indexing and expiry with verified pack-batch replacement and direct retirement of covered inputs. Example: Hourly maintenance finds 32 eligible packs in one group.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it removes unbounded repository-wide indexing through the existing maintenance owner, with no discrete correctness finding; the acknowledged lookup-performance tradeoff remains unresolved. Priority: P2 Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherManaged-worktree housekeeping inventories registered repositories, shares Git mutation ownership with managed fetches, and produces consolidated packs and maintenance progress receipts. flowchart TD
A[Hourly housekeeping or explicit GC] --> B[Managed worktree service]
B --> C[Repository maintenance owner]
C --> D[Git mutation queue and content slot]
D --> E[Bounded pack verification]
E --> F[Native replacement publication]
F --> G[Selected input retirement]
G --> H[Pack indexes and progress receipts]
Technical reviewBest possible solution: Keep the single bounded maintenance owner and settle the object-lookup tradeoff before landing. Do we have a high-confidence way to reproduce the issue? Current-main source shows bounded pack selection followed by repository-wide MIDX writing, and the PR reports two baseline-failing regressions; this read-only review ran no target code. Is this the best way to solve the issue? The patch removes the global operation at its existing owner, preserves native pack publication and verification, and avoids a second scheduler or memory watcher; its lookup-cost tradeoff still needs resolution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6f88c26dcf82. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +20, Tests +99, Docs 0, Other +176. Total +295 across 5 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 24, 2026, 12:56 AM ET / 04:56 UTC. |
Remove repository-wide MIDX writing and expiry from hourly housekeeping. Retire only verified inputs after replacement publication, preserve promise groups and pinned packs, and cap index bytes as well as pack bytes. Small duplicate groups defer until the consolidation threshold.
4fd450f to
f25d137
Compare
…claw#182204) * perf(worktrees): bound Git pack maintenance to verified batches Remove repository-wide MIDX writing and expiry from hourly housekeeping. Retire only verified inputs after replacement publication, preserve promise groups and pinned packs, and cap index bytes as well as pack bytes. Small duplicate groups defer until the consolidation threshold. * test(perf): compare lookups after bounded pack consolidation * perf(worktrees): let bounded pack batches converge by size
What Problem This Solves
Hourly managed-worktree housekeeping can rebuild a multi-pack index over every repository object, despite selecting only a bounded pack batch. Both the explicit final write and Git's implicit rebuild inside
multi-pack-index expireescape the batch budget.User Impact
Pack maintenance now retires verified batches without repository-wide MIDX allocation. Git reads objects through individual pack indexes. Pack groups continue making bounded, size-based progress below the old 16-pack threshold. No configuration or schema migration is required.
Why This Change Was Made
Remove MIDX writing/expiry and retire only selected inputs after
index-packpublishes their replacement. Preserve unreachable objects, separate promisor/local groups, kept/cruft packs, an output already matching an input, cancellation, and corrupt-input protection. Invalidate both monolithic and incremental MIDX entry points so stale metadata cannot override pack-local lookup.The 512 MiB/1,024-pack batch budget now also caps index input at 32 MiB, bounding object metadata independently of compression. Trim dominant packs until the smaller inputs together reach the largest selected pack's size; consolidate only if at least two remain. This avoids repeatedly rewriting a large pack for tiny additions while allowing byte-limited batches to continue converging. It does not promise one final pack. CPU/IO priority, single-thread packing, hourly throttling, and five-minute verification/rewrite budgets remain.
This is an input bound, not an OS RSS hard limit. The host-exec memory watcher does not own this Git execution path. Production delta: +23 lines; the growth implements the metadata bound and safe input retirement while deleting full-repository indexing/expiry. No production API or module is added.
Evidence
node scripts/run-vitest.mjs src/agents/worktrees/service.gc-performance.test.ts src/agents/worktrees/service.removal-budget.test.ts src/agents/worktrees/service.gc-empty-maintenance.test.ts --maxWorkers=1: 36 passed, 1 Linux-only skip on macOS, 125.72 s Vitest / 142.60 s wrapper wall time. Real Git integration covers snapshots, partial clones, corrupt inputs, byte/index caps, failed publication, output identity, late pinning, and small-pack convergence without rewriting the dominant pack.git diff --checkpassed. The earlier implementation passed localpnpm tsgo:core; final typecheck and broad platform proof use PR CI. No full local suite/build or Testbox lease.Native probe: 2,097,152 unique 16-byte blobs, 32 MiB payload, approximately 92 MiB packed storage. Linux/Git 2.53.0 measured the removed full MIDX writer at 339.320 ms / 181.648 MiB peak RSS (0.25 s user + 0.06 s system CPU). The candidate launches zero MIDX writers; this is eliminated native work, not a measured total-Gateway RSS reduction or a reproduction of the reported multi-gigabyte incident.
The initial unchanged 32-pack Linux layout showed a real lookup tradeoff: four warmed 4,096-object batches averaged 19.512 ms with MIDX → 29.570 ms without, +10.059 ms / +51.55% (+2.456 µs/object). This result is retained, not labeled noise.
A subsequent native macOS/Git 2.56.0 probe applied the bounded selection twice: 32 → 15 → 2 packs, with all 2,097,152 objects retained and every sampled object identity/type/size verified. On the resulting two-pack layout:
Delta: −1.876 ms / −6.50%, treated as neutral context, not a speedup claim. Earlier Mac 32-pack and 15-pack baselines were unstable; they do not establish a throughput improvement. The Linux follow-up was cancelled before execution after an exclusive-slot wait; fresh Mac baselines were used, never cross-host timing comparisons.
Reproduce with committed
scripts/perf/managed-git-maintenance-measure.ts:--mode prepare-midx --packs 32 --blobs-per-pack 65536, then--mode measure-midx;--consolidateapplies one bounded native batch before measuring reads. These probes exercise native Git commands, not the complete maintenance owner. Consolidation itself, total process-tree RSS, V8 GC/promotion, and Gateway RPC latency were not measured. No short GC/pause percentile or uncalibrated relative outlier was used as a rejection gate. The landing rationale is removed unbounded work, real Git integrity proof, and neutral resulting-layout context rather than a claimed latency win. Many retained oversized packs may still incur a pack-local lookup cost; no production deployment or live before/after claim is made.Related: #182086.