git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Pearce <spearce@spearce.org>
To: git@vger.kernel.org
Subject: Why do base objects appear behind the delta in packs?
Date: Tue, 29 Aug 2006 09:42:33 -0400	[thread overview]
Message-ID: <20060829134233.GA21335@spearce.org> (raw)

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;
 }
 

             reply	other threads:[~2006-08-29 13:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-29 13:42 Shawn Pearce [this message]
2006-08-29 14:40 ` Why do base objects appear behind the delta in packs? Nicolas Pitre
2006-08-29 14:58 ` Jakub Narebski
2006-08-29 16:27   ` Shawn Pearce
2006-08-29 17:34     ` Junio C Hamano
2006-08-29 17:44       ` Shawn Pearce
2006-08-29 18:16         ` Nicolas Pitre
2006-08-29 18:32           ` Shawn Pearce
2006-08-29 19:23             ` Jon Smirl

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=20060829134233.GA21335@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    /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).