{"thread":{"id":"51004","subject":"[PATCH] gc: avoid permanent repacking if pack size limit is in effect","startedAt":"2019-04-28T08:07:10Z","lastAt":"2019-04-28T08:07:10Z","messageCount":1,"participants":["Valentin Nechayev"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"374610","messageId":"20190428080138.GM599@netch.kiev.ua","threadId":"51004","inReplyTo":null,"subject":"[PATCH] gc: avoid permanent repacking if pack size limit is in effect","fromName":"Valentin Nechayev","fromEmail":"netch@netch.kiev.ua","sentAt":"2019-04-28T08:01:38Z","receivedAt":"2019-04-28T08:07:10Z","isPatch":true,"sender":{"key":"netch@netch.kiev.ua","avatar":null},"body":"With pack.packSizeLimit, a really huge repository can suffer from\nrepacking on any operation with it, because git detects too many\npacks and tries merging them.\n\nSetting gc.autoPackLimit cures the symptom but causes small pack\nmerge to be avoided at all, which isn't the good behavior we want.\n\nFix this by counting only packs that are relatively small. With\ncurrent filesystem behavior, the margin of 1/4 of pack size limit\nlooks a good default.\n---\n builtin/gc.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 8943bcc3..0273d6e5 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -48,6 +48,7 @@ static const char *gc_log_expire = \"1.day.ago\";\n static const char *prune_expire = \"2.weeks.ago\";\n static const char *prune_worktrees_expire = \"3.months.ago\";\n static unsigned long big_pack_threshold;\n+static unsigned long pack_size_limit = 0;\n static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;\n \n static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT;\n@@ -155,6 +156,7 @@ static void gc_config(void)\n \tgit_config_get_expiry(\"gc.logexpiry\", &gc_log_expire);\n \n \tgit_config_get_ulong(\"gc.bigpackthreshold\", &big_pack_threshold);\n+\tgit_config_get_ulong(\"pack.packsizelimit\", &pack_size_limit);\n \tgit_config_get_ulong(\"pack.deltacachesize\", &max_delta_cache_size);\n \n \tgit_config(git_default_config, NULL);\n@@ -229,9 +231,11 @@ static int too_many_packs(void)\n \t\tif (p->pack_keep)\n \t\t\tcontinue;\n \t\t/*\n-\t\t * Perhaps check the size of the pack and count only\n-\t\t * very small ones here?\n+\t\t * Check the size of the pack and count only\n+\t\t * relatively small ones here.\n \t\t */\n+\t\tif (pack_size_limit > 0 && p->pack_size >= pack_size_limit / 4)\n+\t\t\tcontinue;\n \t\tcnt++;\n \t}\n \treturn gc_auto_pack_limit < cnt;\n-- \n2.17.1\n\n"}]}