git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gc: avoid permanent repacking if pack size limit is in effect

From
VNValentin Nechayev <netch@netch.kiev.ua>
Date
Apr 28, 2019, 08:01 UTC
Message-ID
<20190428080138.GM599@netch.kiev.ua>

With pack.packSizeLimit, a really huge repository can suffer from repacking on any operation with it, because git detects too many packs and tries merging them.

Setting gc.autoPackLimit cures the symptom but causes small pack merge to be avoided at all, which isn't the good behavior we want.

Fix this by counting only packs that are relatively small. With
current filesystem behavior, the margin of 1/4 of pack size limit
looks a good default.
---
 builtin/gc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 8943bcc3..0273d6e5 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -48,6 +48,7 @@ static const char *gc_log_expire = "1.day.ago";
 static const char *prune_expire = "2.weeks.ago";
 static const char *prune_worktrees_expire = "3.months.ago";
 static unsigned long big_pack_threshold;
+static unsigned long pack_size_limit = 0;
 static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
 
 static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT;
@@ -155,6 +156,7 @@ static void gc_config(void)
 	git_config_get_expiry("gc.logexpiry", &gc_log_expire);
 
 	git_config_get_ulong("gc.bigpackthreshold", &big_pack_threshold);
+	git_config_get_ulong("pack.packsizelimit", &pack_size_limit);
 	git_config_get_ulong("pack.deltacachesize", &max_delta_cache_size);
 
 	git_config(git_default_config, NULL);
@@ -229,9 +231,11 @@ static int too_many_packs(void)
 		if (p->pack_keep)
 			continue;
 		/*
-		 * Perhaps check the size of the pack and count only
-		 * very small ones here?
+		 * Check the size of the pack and count only
+		 * relatively small ones here.
 		 */
+		if (pack_size_limit > 0 && p->pack_size >= pack_size_limit / 4)
+			continue;
 		cnt++;
 	}
 	return gc_auto_pack_limit < cnt;
-- 
2.17.1
Message 1 of 1 in “gc: avoid permanent repacking if pack size limit is in effect”
  1. gc: avoid permanent repacking if pack size limit is in effectValentin Nechayev, Apr 28, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.