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

[PATCH] change the unpack limit treshold to a saner value

From
Nicolas Pitre <nico@cam.org>
Date
Dec 6, 2006, 21:08 UTC
Message-ID
<Pine.LNX.4.64.0612061420410.2630@xanadu.home>

Let's assume the average object size is x. Given n objects, the needed storage size is n*(x + b), where b is the average wasted block size on disk.

If those objects are packed, the needed storage becomes n*x + b so we save on the block overhead. But there is the pack index which is 1024 + n*24 + b.

Trying to find the value of n where packed objects become an advantage, we have:

	n*x + n*b > n*x + n*24 + 2*b + 1024
	n*b - 2*b > n*24 + 1024
	(n - 2)*b > n*24 + 1024

So given this we need at least 3 objects for the whole to use more space than a pack, and only if b is greater than 1096. Since a common block size is 4096 then the value of b is likely to converge towards 2048. 3 objects is also where more directory entries are used over an constant of 2 for a pack (assuming that both objects would end up with the same first 2 bytes of hash which is overly optimistic). So 3 should be the optimal number of objects for not exploding a pack. And of course larger packs are likely to take even less space due to delta compression kicking in.

This is why I think the current default treshold should be 3 instead of the insane value of 5000. But since it feels a bit odd to go from 5000 to 3 I setled on 10.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---
Sidenote: I think it is OK for pushes to _not_ use thin packs.  When 
not exploding thin packs, they must be completed by adding objects 
creating duplicates and using more disk space.  The penalty for not 
using thin packs is a slight increase in bandwidth for push operations, 
but since pushes are normally much less frequent than fetches it seems 
OK to penalize the push a bit for a better disk usage on servers.
diff --git a/receive-pack.c b/receive-pack.c
index d62ed5b..9140312 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -11,7 +11,7 @@
 static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
 
 static int deny_non_fast_forwards = 0;
-static int unpack_limit = 5000;
+static int unpack_limit = 10;
 static int report_status;
 
Next: Junio C Hamano
Message 1 of 8 in “change the unpack limit treshold to a saner value”
  1. change the unpack limit treshold to a saner valueNicolas Pitre, Dec 6, 2006
  2. Junio C HamanoDec 6, 2006
  3. Nicolas PitreDec 7, 2006
  4. Linus TorvaldsDec 7, 2006
  5. Nicolas PitreDec 7, 2006
  6. Linus TorvaldsDec 7, 2006
  7. change the unpack limit treshold to a saner valueNicolas Pitre, Dec 7, 2006
  8. Shawn PearceDec 7, 2006

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.