Skip to content

Use geometric repack instead of gc --auto for mirror maintenance - #48

Open
Trent-TSE wants to merge 3 commits into
mainfrom
devin/1788300263-geometric-mirror-repack
Open

Trent-TSE wants to merge 3 commits into
mainfrom
devin/1788300263-geometric-mirror-repack

Conversation

@Trent-TSE

@Trent-TSE Trent-TSE commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Post-job mirror maintenance (runMirrorGC) now runs git repack -d --geometric=2 (plus git pack-refs --all --prune) instead of git gc --auto.

Why: every mirror sync fetch runs with gc.auto=0, so each committed sync adds one pack. Once the mirror crosses gc.autoPackLimit (50 packs), gc --auto does a full repack -A -d of every pack, including the multi-GB base pack from hydration (no gc.bigPackThreshold is set). On large monorepos that blows through GC_TIMEOUT_SECS (120s), and because a timed-out GC blocks the sticky-disk commit, the mirror stays over the threshold and every subsequent job with a changed mirror re-attempts the same full repack — visible as bursts of GC timed out after 120s / will not commit sticky disk warnings with ~2-minute post steps, until one job happens to finish inside the window. (The other --auto trigger, >6700 loose objects, only runs an incremental repack -d -l and is cheap; the pack-count trigger is the one that hurts.)

A geometric repack only rolls up the packs (and loose objects) needed to keep pack object counts in a factor-2 progression, so the base pack is never rewritten and the per-run cost is proportional to what recent syncs added; when the progression already holds it's a near no-op (Nothing new to pack.).

- timeout 120 git -c gc.autoDetach=false -C <mirror> gc --auto
+ timeout 120 git -C <mirror> repack -d --geometric=2
+ timeout 120 git -C <mirror> pack-refs --all --prune   # non-fatal
  • --geometric needs git ≥ 2.32 (supportsGeometricRepack() parses git version); older gits keep the previous gc --auto path unchanged.
  • Timeout / exit-code handling and the fail-safe "no commit on GC failure" semantics in cleanup() are unchanged. Everything still runs in the foreground so nothing is left holding the mount at umount.
  • pack-refs replaces the ref packing gc used to do so loose refs from sync fetches don't accumulate; failure only warns (loose refs shadow packed-refs with identical values, so a partial run is harmless).
  • A git count-objects -v summary is logged before maintenance ([git-mirror] Object store: packs=N, size-pack=…KiB, loose=N, …) so pack/loose counts can be correlated with maintenance time in real job logs.
  • Trade-off: repack --geometric does not prune unreachable objects (no -A/prune), so objects from force-pushed/deleted branches stay in the mirror until it's re-hydrated. That growth is slow relative to the repo itself and is preferable to a maintenance step that can never complete.

dist/index.js rebuilt via npm run build.

Link to Devin session: https://app.devin.ai/sessions/42f58c11558242bdb1bfc805782f9ae9
Open in Devin Desktop: https://app.devin.ai/desktop/session/42f58c11558242bdb1bfc805782f9ae9?variant=devin
Requested by: @Trent-TSE


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled. (Staging)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@linear-code

linear-code Bot commented Sep 1, 2026

Copy link
Copy Markdown

BLA-4660

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 74fe243. Configure here.

Comment thread src/blacksmith-cache.ts Outdated
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant