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

Re: How to unpack recent objects?

From
Nicolas Pitre <nico@fluxnic.net>
Date
Dec 16, 2010, 23:12 UTC
Message-ID
<alpine.LFD.2.00.1012161743530.10437@xanadu.home>
In-Reply-To
<4D0A8D83.9080705@cfl.rr.com>
On Thu, 16 Dec 2010, Phillip Susi wrote:
Show 9 quoted lines
> On 12/16/2010 4:19 PM, Nicolas Pitre wrote:
> > What makes you think that unpacking them will actually make the access 
> > to them faster?  Instead, you should consider _repacking_ them, 
> > ultimately using the --aggressive parameter with the gc command, if you 
> > want faster accesses.
> 
> Because decompressing and undeltifying the objects in the pack file
> takes a fair amount of cpu time.  It seems a waste to do this for the
> same set of objects repeatedly rather than just keeping them loose.
Well, here are a couple implementation details you might not know about:
1) Loose objects are compressed too.  So you gain nothing on that front 
   by keeping objects loose.
2) Delta ordering is so that recent objects, i.e. those belonging to 
   most recent commits, are not delta compressed but rather used as base 
   objects for "older" objects to delta against.  So in practice, the 
   cost of undeltifying objects is pushed towards objects that you're 
   most unlikely to access frequently.
3) Object placement within the pack is also optimized so that 
   objects belonging to recent commits are close together, and walking 
   them creates a linear IO access pattern which is much faster than 
   accessing random individual files as loose objects are.
4) Packed objects take considerably less space than loose ones which 
   makes for much better usage of the file system cache in the operating 
   system.  This largely outweights the cost of undeltifying objects.
5) Git also keeps a cache of most frequently referenced objects when 
   replaying delta chains so deep deltas don't bring exponential costs.

And, in some cases, Git does even pick up the content of an object by using its checked out form in the working directory directly instead of locating and decompressing the object data.

So you shouldn't have to worry on that front. Git is not the fastest SCM out there just by luck.

Nicolas
Previous: Jakub Narebski
Message 6 of 6 in “How to unpack recent objects?”
  1. Phillip SusiDec 16, 2010
  2. Jonathan NiederDec 16, 2010
  3. Nicolas PitreDec 16, 2010
  4. Phillip SusiDec 16, 2010
  5. Jakub NarebskiDec 16, 2010
  6. Nicolas PitreDec 16, 2010

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.