You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(git): add periodic full repack to shrink mirrors and snapshots
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
Copy file name to clipboardExpand all lines: internal/gitclone/manager.go
+57-7Lines changed: 57 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -65,8 +65,19 @@ type Config struct {
65
65
LsRemoteTimeout time.Duration`hcl:"ls-remote-timeout,optional" help:"Upper bound for 'git ls-remote' so a slow upstream cannot block the request path indefinitely." default:"1m"`
66
66
RepackTimeout time.Duration`hcl:"repack-timeout,optional" help:"Upper bound for 'git repack' so a slow repack on a large repository cannot block the scheduler queue indefinitely." default:"10m"`
67
67
RepackThreadsint`hcl:"repack-threads,optional" help:"Threads for git repack operations. Limits memory since windowMemory and deltaCacheSize are per-thread. 0 = pack-threads." default:"4"`
68
+
69
+
FullRepackTimeout time.Duration`hcl:"full-repack-timeout,optional" help:"Upper bound for the full (delta-recomputing) repack, which is far slower than the geometric repack on large repositories. 0 falls back to repack-timeout." default:"1h"`
68
70
}
69
71
72
+
// Delta search window and chain depth for the full repack. A wider window finds
73
+
// tighter deltas (smaller packs) at the cost of more CPU; these values were
74
+
// chosen empirically. Not configurable: tuning them changes the size/CPU
75
+
// tradeoff in ways that can't be reasoned about without re-benchmarking.
76
+
const (
77
+
fullRepackWindow=100
78
+
fullRepackDepth=50
79
+
)
80
+
70
81
// CredentialProvider provides credentials for git operations.
SnapshotInterval time.Duration`hcl:"snapshot-interval,optional" help:"How often to generate tar.zstd workstation snapshots. 0 disables snapshots." default:"0"`
48
48
MirrorSnapshotInterval time.Duration`hcl:"mirror-snapshot-interval,optional" help:"How often to generate mirror snapshots for pod bootstrap. 0 uses snapshot-interval. Defaults to 2h." default:"2h"`
49
-
RepackInterval time.Duration`hcl:"repack-interval,optional" help:"How often to run full repack. 0 disables." default:"0"`
49
+
RepackInterval time.Duration`hcl:"repack-interval,optional" help:"How often to run the geometric repack (consolidates packs, reuses deltas). 0 disables." default:"0"`
50
+
FullRepackInterval time.Duration`hcl:"full-repack-interval,optional" help:"How often to run the full repack (re-selects deltas across all objects, shrinking the mirror). Far more expensive than the geometric repack, so use a slow cadence. 0 disables." default:"0"`
50
51
ZstdThreadsint`hcl:"zstd-threads,optional" help:"Threads for zstd compression/decompression. 0 = all CPU cores; useful for short-lived CLI invocations but risky on a long-running server where multiple snapshot/restore operations can run concurrently." default:"4"`
51
52
BundleCacheTTL time.Duration`hcl:"bundle-cache-ttl,optional" help:"TTL of cached server-side git bundles." default:"2h"`
0 commit comments