feat(git): add periodic full repack to shrink mirrors and snapshots#323
Draft
worstell wants to merge 1 commit into
Draft
feat(git): add periodic full repack to shrink mirrors and snapshots#323worstell wants to merge 1 commit into
worstell wants to merge 1 commit into
Conversation
e0fe499 to
39c740b
Compare
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
39c740b to
f0c9bba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.RepackFullruns the delta-recomputing repack; existingRepack(geometric) is unchanged. Both share arunRepackhelper.full-repack-intervalschedules it independently ofrepack-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.operation(repackvsrepack_full).Validation
RepackFull(config fallbacks) and scheduling;go build,go test,golangci-lintpass.go-squaresnapshot → 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.