Skip to content

perf(worktrees): retire redundant packs before bounded consolidation - #170935

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-project-repo-pack-explosion-20260919
Oct 13, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-project-repo-pack-explosion-20260919

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Large redundant Git packs in managed project repositories can survive indefinitely when they exceed the 512 MiB consolidation rewrite budget or fewer than 16 packs remain.

User Impact

Hourly managed-worktree maintenance can reclaim duplicate transfers without rewriting their objects. Unique objects, worktree/reflog history, kept packs, cruft packs, and promisor classification remain preserved. Updates require no migration; the next maintenance pass applies the repair.

Why This Change Was Made

Before selecting a bounded rewrite batch, publish a MIDX for each eligible promisor class and expire packs with no selected objects. Prefer the largest pack so overlapping transfers can retire smaller redundant copies. Rescan the surviving files and retain the existing bounded consolidation for distinct small packs. Publish one final MIDX covering every remaining pack.

Ordinary project refresh already seeds its isolated transport repository with the managed remote-tracking refs, and default-base fetches already negotiate incrementally. No speculative fetch or agent-exec policy change is included. Repository failures are already isolated by the existing maintenance owner. Unreachable-object retention and cruft handling remain with Git’s existing contracts; this does not add full GC or pruning.

Production LOC: +4 (21 added / 17 deleted). Separate promisor-class expiry and a rescan after deletion are required to avoid displacing promises with ordinary copies; the obsolete initial full-index write and conditional final-index path were removed.

Evidence

  • Real production maintenance regression: recreate a redundant promisor transfer after consolidation, then run a second pass below the rewrite threshold. It returns to three packs / two promisor markers and preserves the blob and a valid MIDX.

  • Focused local proof: pnpm test src/agents/worktrees/service.gc-performance.test.ts src/projects/project-registry.test.ts --maxWorkers=1 — 48 passed, 1 Linux-only skip, 233.83 s wall. Changed maintenance file: 99.28 s total; consolidation/regression case: 1.682 s. Per-file CI timing was not collected; full CI passed on the exact head.

  • Changed-file oxfmt, repository oxlint with type-aware rules, and git diff --check passed. No Testbox/Crabbox lease was allocated; broad gates belong to PR CI.

  • Independent subagent review (autoreview route unavailable): no actionable P1/P2 findings. Autoreview preflight refused the requested provider because it did not match the operator configuration; configuration was unchanged.

  • Isolated Linux sandbox, public repository history and synthetic fixtures, real refreshProjectCheckout, default-base fetch, and both baseline/candidate maintenance owners: 24 unchanged refreshes created zero packs (4.17 s total). A simulated day with 96 updates and 24 hourly maintenance passes peaked at 6 packs and ended at 333,553 bytes (34.24 s total). The public history was supplied by a separate immutable sandbox object donor; new synthetic remote objects were transferred independently.

  • Corrected large-transfer measurement (forced independent encodings of the same 320 MiB blob): baseline left 8 packs / 671,549,899 bytes unchanged; candidate retired the redundant large pack, leaving 7 packs / 335,979,931 bytes. Reclaimed 335,569,968 bytes without a pack rewrite. Unique-blob size and MIDX verification passed. Baseline maintenance took 4,612 ms including cold state-worker startup; the candidate took 84 ms with warm workers, so these timings are not a maintenance speedup claim.

  • Identical public seven-day git log --numstat output: 35.75 s before / 36.40 s after (+1.8%, neutral within single-sample noise). This repair targets redundant disk storage and pack lookup rather than Git’s inherent diff traversal cost.

  • Exact-head broad proof: CI run 38381066342 passed on c0eee93bb7ae2f2d112bcb53cec9b75b8c911d91, including static checks, changed Node lanes, and both UI end-to-end shards. Security review and its final refresh passed. No failed job or CI rerun occurred.

Limits: this does not establish the writer responsible for a particular existing repository’s pack backlog, guarantee a fixed pack count for arbitrarily growing unique large packs, or change Git’s inherent log --numstat traversal cost. The full public seven-day traversal took approximately 41 s even with one donor pack. External Git readers/writers use Git’s existing publication/expiry guarantees; no new cross-process ownership protocol was introduced.

@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T10:11:11.536053Z c0eee93 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 13, 2026
@steipete
steipete merged commit b8091af into main Oct 13, 2026
130 of 131 checks passed
@steipete
steipete deleted the steipete/perf-micro-project-repo-pack-explosion-20260919 branch October 13, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant