git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Pitre <nico@cam.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Brian Downing <bdowning@lavos.net>, git@vger.kernel.org
Subject: [PATCH] apply delta depth bias to already deltified objects
Date: Thu, 12 Jul 2007 14:33:21 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.0.999.0707121415450.32552@xanadu.home> (raw)
In-Reply-To: <alpine.LFD.0.999.0707120049120.32552@xanadu.home>

We already apply a bias on the initial delta attempt with max_size being 
a function of the base object depth.  This has the effect of favoring 
shallower deltas even if deeper deltas could be smaller, and therefore 
creating a wider delta tree (see commits 4e8da195 and c3b06a69).

This principle should also be applied to all delta attempts for the same 
object and not only the first attempt.  With this the criteria for the 
best delta is not only its size but also its depth, so that a shallower 
delta might be selected even if it is larger than a deeper one.  Even if 
some deltas get larger, they allow for wider delta trees making the 
depth limit less quickly reached and therefore better deltas can be 
subsequently found, keeping the resulting pack size even smaller.  
Runtime access to the pack should also benefit from shallower deltas.

Testing on different repositories showed slighter faster repacks, 
smaller resulting packs, and a much nicer curve for delta depth 
distribution with no more peak at the maximum depth level.  
Improvements are even more significant with smaller depth limits.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---

No, I wonn't provide the full test results again.  Yes, they're 
different and even slightly better with this version, but I can't be 
bothered to run them all and wait for the results again.  You'll have to 
take my word or do your own.

diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 54b9d26..b4f3e7c 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1303,6 +1303,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 	struct object_entry *trg_entry = trg->entry;
 	struct object_entry *src_entry = src->entry;
 	unsigned long trg_size, src_size, delta_size, sizediff, max_size, sz;
+	unsigned ref_depth;
 	enum object_type type;
 	void *delta_buf;
 
@@ -1332,12 +1333,17 @@ 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;
-	max_size = max_size * (max_depth - src_entry->depth) / max_depth;
+	if (!trg_entry->delta) {
+		max_size = trg_size/2 - 20;
+		ref_depth = 1;
+	} else {
+		max_size = trg_entry->delta_size;
+		ref_depth = trg_entry->depth;
+	}
+	max_size = max_size * (max_depth - src_entry->depth) /
+						(max_depth - ref_depth + 1);
 	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)

      parent reply	other threads:[~2007-07-12 18:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-12  6:38 [PATCH] apply delta depth bias to already deltified objects Nicolas Pitre
2007-07-12 15:20 ` Brian Downing
2007-07-12 16:27   ` Nicolas Pitre
2007-07-12 16:44     ` Brian Downing
2007-07-12 18:07       ` Nicolas Pitre
2007-07-12 18:33 ` Nicolas Pitre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.0.999.0707121415450.32552@xanadu.home \
    --to=nico@cam.org \
    --cc=bdowning@lavos.net \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).