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

Why do base objects appear behind the delta in packs?

From
Shawn Pearce <spearce@spearce.org>
Date
Aug 29, 2006, 13:42 UTC
Message-ID
<20060829134233.GA21335@spearce.org>
Sorry but this really is a pretty stupid question on my part:

In builtin-pack-objects.c write_one(), why is the base object written behind the first delta that depends on it (if it hasn't been written already) rather than BEFORE the first delta that depends on it?

If the base always had to appear before any delta that uses it then unpack-objects wouldn't need to cache a delta in memory waiting for the base to get unpacked.

>From a data locality perspective putting the base object before

or after the delta shouldn't matter, as either way the delta is useless without the base. So placing the base immediately before the delta should perform just as well as placing it after. Either way the OS should have the base in cache by the time the delta is being accessed.

In other words, why not apply this patch and make it a requirement of the pack file format?

diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 46f524d..5dd97b9 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -341,11 +341,11 @@ static unsigned long write_one(struct sh
 		 * if it is written already.
 		 */
 		return offset;
-	e->offset = offset;
-	offset += write_object(f, e);
 	/* if we are deltified, write out its base object. */
 	if (e->delta)
 		offset = write_one(f, e->delta, offset);
+	e->offset = offset;
+	offset += write_object(f, e);
 	return offset;
 }
 
Next: Nicolas Pitre
Message 1 of 9 in “Why do base objects appear behind the delta in packs?”
  1. Shawn PearceAug 29, 2006
  2. Nicolas PitreAug 29, 2006
  3. Jakub NarebskiAug 29, 2006
  4. Shawn PearceAug 29, 2006
  5. Junio C HamanoAug 29, 2006
  6. Shawn PearceAug 29, 2006
  7. Nicolas PitreAug 29, 2006
  8. Shawn PearceAug 29, 2006
  9. Jon SmirlAug 29, 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.