Skip to content

feat(git): add periodic full repack to shrink mirrors and snapshots#323

Draft
worstell wants to merge 1 commit into
mainfrom
worstell/aggressive-full-repack
Draft

feat(git): add periodic full repack to shrink mirrors and snapshots#323
worstell wants to merge 1 commit into
mainfrom
worstell/aggressive-full-repack

Conversation

@worstell

@worstell worstell commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Mirrors are kept current with frequent incremental fetches, each packing its objects with a narrow delta window, so they accumulate redundant deltas over time. The existing geometric repack only merges packs and reuses those deltas, never recovering the waste.

This adds a full repack (git repack -a -d -f --window --depth) that recomputes deltas across all objects, shrinking the mirror — and therefore every snapshot derived from it, since a snapshot is essentially the mirror's packfiles. Runs on a slow cadence, separate from the frequent geometric repack, and disabled by default.

Design

  • Repository.RepackFull runs the delta-recomputing repack; existing Repack (geometric) is unchanged. Both share a runRepack helper.
  • full-repack-interval schedules it independently of repack-interval; full-repack-timeout (1h) is configurable. Window (100) and depth (50) are constants — tuning them shifts the size/CPU tradeoff in ways that need re-benchmarking, so they are not exposed.
  • Metrics/traces tag the variant via operation (repack vs repack_full).

Validation

  • Unit tests cover RepackFull (config fallbacks) and scheduling; go build, go test, golangci-lint pass.
  • Staging benchmark: replayed the bounded repack against a live go-square snapshot → 5993 MB → 3818 MB (~36%) in ~25 min, inside the 1h timeout. A playpen can't show this — a fresh mirror lacks the accumulated fragmentation.

@worstell worstell marked this pull request as ready for review June 11, 2026 20:13
@worstell worstell requested a review from a team as a code owner June 11, 2026 20:13
@worstell worstell requested review from joshfriend and removed request for a team June 11, 2026 20:13
@worstell worstell force-pushed the worstell/aggressive-full-repack branch 2 times, most recently from e0fe499 to 39c740b Compare June 11, 2026 20:34
@worstell worstell marked this pull request as draft June 11, 2026 22:05
Mirrors are maintained by incremental fetches, each of which packs only
its own objects with a narrow delta window. Over time this accumulates
suboptimal, cross-pack-redundant deltas. The existing geometric repack
consolidates packs but reuses those deltas, so it never recovers the
redundancy.

Add a separate full repack (git repack -a -d -f --window --depth) that
re-selects deltas across all objects, materially shrinking the mirror and
the snapshots derived from it, in exchange for significant one-time CPU.
It runs on its own slow cadence (full-repack-interval) alongside the
frequent geometric repack, and is disabled by default. Window, depth, and
timeout are configurable.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019eae3d-a2fd-70ca-80fe-a7536ec6748c
@worstell worstell force-pushed the worstell/aggressive-full-repack branch from 39c740b to f0c9bba Compare June 11, 2026 22:05
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