Is there a way to limit the amount of memory that “git gc” uses?

后端 未结 5 1922
太阳男子
太阳男子 2020-11-29 00:12

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

5条回答
  •  执笔经年
    2020-11-29 01:03

    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.

提交回复
热议问题