By admin , 29 April 2026

Repack budgets

When Git computes deltas during repack, it considers a window of candidate base objects per target. Larger windows produce smaller packs but use more memory and CPU. Tuning is essential for huge repos and constrained build runners alike.

Key knobs

[pack]
windowMemory = 256m       # max RAM per delta-search worker
threads = 0               # 0 = auto-detect cores
deltaCacheSize = 256m     # cache for in-flight deltas
deltaCacheLimit = 1000    # objects beyond this size skip cache
window = 10               # default delta window size
depth = 50                # max delta chain depth
sizeLimit = 2g            # split packs larger than this
bigFileThreshold = 512m   # treat above as binary, no delta

Repacking with custom budgets

git repack -adf --window=250 --depth=50 \
  --window-memory=512m --threads=8 \
  --write-midx --write-bitmap-index

The -f flag forces full delta recomputation rather than reusing existing deltas, important after big imports.

Memory math

Total memory roughly equals pack.threads × pack.windowMemory + pack.deltaCacheSize. On a 16-core box with 256m windows and 256m cache, that's ~4.3GB during repack. Constrain on small runners:

git -c pack.threads=2 -c pack.windowMemory=128m repack -adf

Server tuning

Shared Git servers serve many concurrent fetches that each spawn pack workers. Limit per-process memory:

[uploadpack]
packObjectsHook = /usr/local/bin/pack-objects-wrapper
[pack]
threads = 4
windowMemory = 128m

Big file threshold

Files above core.bigFileThreshold (default 512m) are stored undeltified, saving CPU at the cost of disk. Useful when your repo has occasional huge binary blobs.

git config core.bigFileThreshold 50m

Common mistakes

Setting --window=2000 hoping for tighter packs without testing memory — OOM follows. Pinning pack.threads=1 on a multi-core runner, leaving 90% of CPU idle. Forgetting that --aggressive overrides defaults to depth=250, window=250 — never use it on a CI box.

Measuring effect

du -sh .git/objects/pack/
git verify-pack -v .git/objects/pack/pack-*.idx | tail -3
GIT_TRACE2_PERF=1 git repack -adf 2>&1 | tail -20

Related

See "Geometric repacking strategy", "Multi-pack-index (MIDX): unified pack object lookup", and "Configuration playbook for large repositories".