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

[PATCH 6/6] pack-objects: reuse deltas for thin "have" objects

From
Jeff King <peff@peff.net>
Date
Mar 26, 2014, 07:23 UTC
Message-ID
<20140326072338.GF32193@sigill.intra.peff.net>
In-Reply-To
<20140326072215.GA31739@sigill.intra.peff.net>

When we calculate the "wants" and "haves" for a pack, we only add the objects in the boundary commits as preferred bases. However, we know that every object reachable from the "haves" could be a preferred base.

We probably don't want to add these to our preferred base list, because they would clog the delta-search window. However, there is no reason we cannot reuse an on-disk delta against such a deep "have" base, avoiding the delta search for that object altogether.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/pack-objects.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 7950c43..92bd682 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -53,6 +53,7 @@ static unsigned long pack_size_limit;
 static int depth = 50;
 static int delta_search_threads;
 static int pack_to_stdout;
+static int thin = 0;
 static int num_preferred_base;
 static struct progress *progress_state;
 static int pack_compression_level = Z_DEFAULT_COMPRESSION;
@@ -1419,6 +1420,20 @@ static void check_object(struct object_entry *entry)
 			base_entry->delta_child = entry;
 			unuse_pack(&w_curs);
 			return;
+		} else if(thin && base_ref && bitmap_have(base_ref)) {
+			entry->type = entry->in_pack_type;
+			entry->delta_size = entry->size;
+			/*
+			 * XXX we'll leak this, but it's probably OK
+			 * since we'll exit immediately after the packing
+			 * is done
+			 */
+			entry->delta = xcalloc(1, sizeof(*entry->delta));
+			hashcpy(entry->delta->idx.sha1, base_ref);
+			entry->delta->preferred_base = 1;
+			entry->delta->filled = 1;
+			unuse_pack(&w_curs);
+			return;
 		}
 
 		if (entry->type) {
@@ -2559,7 +2574,6 @@ static int option_parse_ulong(const struct option *opt,
 int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 {
 	int use_internal_rev_list = 0;
-	int thin = 0;
 	int all_progress_implied = 0;
 	const char *rp_av[6];
 	int rp_ac = 0;
-- 
1.9.1.601.g7ec968e
Previous: Jeff KingNext: Eric Sunshine
Message 8 of 17 in “reuse deltas found by bitmaps”
  1. 0/6 reuse deltas found by bitmapsJeff King, Mar 26, 2014
  2. 1/6 t/perf-lib: factor boilerplate out of test_perfJeff King, Mar 26, 2014
  3. Junio C HamanoMar 26, 2014
  4. 2/6 t/perf/aggregate: factor our percent calculationsJeff King, Mar 26, 2014
  5. 3/6 t/perf: add infrastructure for measuring sizesJeff King, Mar 26, 2014
  6. 4/6 t/perf: add perf tests for fetches from a bitmapped serverJeff King, Mar 26, 2014
  7. 5/6 pack-bitmap: save "have" bitmap from walkJeff King, Mar 26, 2014
  8. 6/6 pack-objects: reuse deltas for thin "have" objectsJeff King, Mar 26, 2014
  9. Eric SunshineMar 28, 2014
  10. Junio C HamanoMar 26, 2014
  11. Jeff KingMar 26, 2014
  12. Junio C HamanoMar 26, 2014
  13. Jeff KingMar 26, 2014
  14. Jeff KingMar 27, 2014
  15. Junio C HamanoMar 27, 2014
  16. Siddharth AgarwalMar 26, 2014
  17. Siddharth AgarwalMar 27, 2014

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.