I\'m hosting a git repo on a shared host. My repo necessarily has a couple of very large files in it, and every time I try to run \"git gc\" on the repo now, my process get
Git repack's memory use is: (pack.deltaCacheSize + pack.windowMemory) × pack.threads
. Respective defaults are 256MiB, unlimited, nproc.
The delta cache isn't useful: most of the time is spent computing deltas on a sliding window, the majority of which are discarded; caching the survivors so they can be reused once (when writing) won't improve the runtime. That cache also isn't shared between threads.
By default the window memory is limited through pack.window
(gc.aggressiveWindow
). Limiting packing that way is a bad idea, because the working set size and efficiency will vary widely. It's best to raise both to much higher values and rely on pack.windowMemory
to limit the window size.
Finally, threading has the disadvantage of splitting the working set. Lowering pack.threads
and increasing pack.windowMemory
so that the total stays the same should improve the run time.
repack has other useful tunables (pack.depth
, pack.compression
, the bitmap options), but they don't affect memory use.