{"thread":{"id":"20412","subject":"[PATCH] don't let the delta cache grow unbounded in 'git repack'","startedAt":"2009-08-05T20:55:07Z","lastAt":"2009-08-05T20:55:07Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"119687","messageId":"alpine.LFD.2.00.0908051639360.16073@xanadu.home","threadId":"20412","inReplyTo":null,"subject":"[PATCH] don't let the delta cache grow unbounded in 'git repack'","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-05T20:55:07Z","receivedAt":"2009-08-05T20:55:07Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"I have 4GB of RAM on my system which should, in theory, be quite enough \nto repack a 600 MB repository.  However the unbounded delta cache size \nalways pushes it into swap, at which point everything virtually comes to \na halt.  So unbounded caches are never a good idea.\n\nA default of 256MB should be a good compromize between memory usage and \nspeed where medium sized repositories are still likely to fit in the \ncache with a reasonable memory usage, and larger repositories are going \nto take quite some time to repack already anyway.\n\nWhile at it, clarify the associated config variable documentation \nentries a bit.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex c6f09f8..7791c32 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1218,12 +1218,20 @@ pack.compression::\n \n pack.deltaCacheSize::\n \tThe maximum memory in bytes used for caching deltas in\n-\tlinkgit:git-pack-objects[1].\n-\tA value of 0 means no limit. Defaults to 0.\n+\tlinkgit:git-pack-objects[1] before writing them out to a pack.\n+\tThis cache is used to speed up the writing object phase by not\n+\thaving to recompute the final delta result once the best match\n+\tfor all objects is found.  Repacking large repositories on machines\n+\twhich are tight with memory might be badly impacted by this though,\n+\tespecially if this cache pushes the system into swapping.\n+\tA value of 0 means no limit. The smallest size of 1 byte may be\n+\tused to virtually disable this cache. Defaults to 256 MiB.\n \n pack.deltaCacheLimit::\n \tThe maximum size of a delta, that is cached in\n-\tlinkgit:git-pack-objects[1]. Defaults to 1000.\n+\tlinkgit:git-pack-objects[1]. This cache is used to speed up the\n+\twriting object phase by not having to recompute the final delta\n+\tresult once the best match for all objects is found. Defaults to 1000.\n \n pack.threads::\n \tSpecifies the number of threads to spawn when searching for best\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 961b639..c433748 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -86,7 +86,7 @@ static int pack_compression_level = Z_DEFAULT_COMPRESSION;\n static int pack_compression_seen;\n \n static unsigned long delta_cache_size = 0;\n-static unsigned long max_delta_cache_size = 0;\n+static unsigned long max_delta_cache_size = 256 * 1024 * 1024;\n static unsigned long cache_max_small_delta_size = 1000;\n \n static unsigned long window_memory_limit = 0;\n"}]}