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

Re: Preferring shallower deltas on repack

From
Nicolas Pitre <nico@cam.org>
Date
Jul 9, 2007, 15:58 UTC
Message-ID
<alpine.LFD.0.999.0707090954550.26459@xanadu.home>
In-Reply-To
<7v1wfixhvk.fsf@assigned-by-dhcp.cox.net>
On Sun, 8 Jul 2007, Junio C Hamano wrote:
Show 5 quoted lines
> It would become worrysome (*BUT* infinitely more interesting)
> once you start talking about a tradeoff between slightly larger
> delta and much shorter delta.  Such a tradeoff, if done right,
> would make a lot of sense, but I do not offhand think of a way
> to strike a proper balance between them efficiently.

We already do something similar to that with max_size being a function of the delta depth. This already has the effect of favoring shalower deltas even if deeper deltas could be smaller, and therefore creating a wider delta tree (see commits 4e8da195 and c3b06a69).

Maybe this max_size curve could be modified a bit to increase the bias towards shallow deltas even in the case where a delta was already found instead of the current constant flat curve.

[...]

OK here it is. And results on the GIT repo and another patalogical test repo I keep around are actually really nice! Not only the pack itself is a bit smaller, but the delta depth distribution as shown by git-verify-pack -v is much nicer with the bulk of deltas in the low depth end of the spectrum and no more peak at the max depth level.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 54b9d26..1eb86ed 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1332,12 +1332,14 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 
 	/* Now some size filtering heuristics. */
 	trg_size = trg_entry->size;
-	max_size = trg_size/2 - 20;
+	if (!trg_entry->delta)
+		max_size = trg_size/2 - 20;
+	else
+		max_size = trg_entry->delta_size * max_depth /
+				(max_depth - trg_entry->depth + 1);
 	max_size = max_size * (max_depth - src_entry->depth) / max_depth;
 	if (max_size == 0)
 		return 0;
-	if (trg_entry->delta && trg_entry->delta_size <= max_size)
-		max_size = trg_entry->delta_size;
 	src_size = src_entry->size;
 	sizediff = src_size < trg_size ? trg_size - src_size : 0;
 	if (sizediff >= max_size)
Previous: Brian DowningNext: Junio C Hamano
Message 8 of 19 in “Preferring shallower deltas on repack”
  1. Brian DowningJul 9, 2007
  2. pack-objects: Prefer shallower deltas if the size is equalBrian Downing, Jul 9, 2007
  3. Junio C HamanoJul 9, 2007
  4. Junio C HamanoJul 9, 2007
  5. Brian DowningJul 9, 2007
  6. Junio C HamanoJul 9, 2007
  7. Brian DowningJul 9, 2007
  8. Nicolas PitreJul 9, 2007
  9. Junio C HamanoJul 9, 2007
  10. Brian DowningJul 9, 2007
  11. Nicolas PitreJul 9, 2007
  12. Brian DowningJul 9, 2007
  13. Brian DowningJul 9, 2007
  14. Nicolas PitreJul 9, 2007
  15. Brian DowningJul 9, 2007
  16. Shoddy pack information toolBrian Downing, Jul 9, 2007
  17. Junio C HamanoJul 11, 2007
  18. Pack information toolBrian Downing, Jul 12, 2007
  19. Linus TorvaldsJul 9, 2007

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.