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

Re: CAREFUL! No more delta object support!

From
Linus Torvalds <torvalds@osdl.org>
Date
Jun 28, 2005, 17:36 UTC
Message-ID
<Pine.LNX.4.58.0506281019450.19755@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.21.0506281251380.30848-100000@iabervon.org>
On Tue, 28 Jun 2005, Daniel Barkalow wrote:
> 
> Actually, the ideal thing would be to move the packing code into an object
> file that git-ssh-push can include; that way it can write directly to the
> socket instead of going through disk

It doesn't work very easily that way because the index file (which contains the object list and the offsets into the pack file) cannot be created until after the pack file has been created (and we don't want to evaluate that one in memory, since it can be quite big).

Now, what we could do is to stream out the pack file first to stdout, and write the index file afterwards. But since we don't know how big the pack file will be when we start packing, and the pack-file can contain basically arbitrary patterns, that requires that the receiver actually parse the pack-file as it comes in.

The format of the pack-file is a fairly trivial data stream of
 - rinse and repeat for each object:
     - one character of type of file (C, T, B, G, D for "commit", "tree", 
       "blob", "tag" or "delta" respectively)
     - four bytes of network-order unpacked data length
     - [ if delta: 20 bytes of delta object ID ]
     - zlib-packed data (length unknown, except we know how much we want 
       it to unpack to)
 - Finally at the end: 20 bytes of SHA1 of the pack-file contents (up to 
   the SHA1)

so it's actually possible to pick up the objects as they come off the stream, since the SHA1 name is defined by the contents and you don't need the index file unless you want to look things up.

So the receiver side could try this algorithm:
 - unpack each object in memory on the receiving side
	If the unpack failed, it must have been the SHA1 at the end, so 
	verify it!
 - if it's a delta object and you haven't seen the object it's a delta 
   against, keep it in memory.
 - if it's a non-delta object, just write it to the object store, and try 
   to resolve any delta objects you have pending that this new object 
   satisfies. That in turn creates other objects that may have more deltas 
   they satisfy etc.

which looks quite doable. The delta objects are small, so keeping them in memory shouldn't be a problem (especially since we _tend_ to write deltas after the object they depend on).

I can certainly add an option to git-pack-file that disables writing of the index file, and just writes the pack-file to stdout. I'm not sure I want to write the "parse incoming pack-file" thing, but git-unpack-objects comes _reasonably_ close (but right now it seeks around using the index file to resolve deltas, instead of keeping them in memory and resolving them when possible). But I can make the infrastructure ready for it.

Sounds like a plan.
			Linus
Previous: Daniel BarkalowNext: Linus Torvalds
Message 26 of 38 in “CAREFUL! No more delta object support!”
  1. Linus TorvaldsJun 28, 2005
  2. Christopher LiJun 27, 2005
  3. Linus TorvaldsJun 28, 2005
  4. Junio C HamanoJun 28, 2005
  5. Christopher LiJun 28, 2005
  6. Petr BaudisJun 28, 2005
  7. Benjamin LaHaiseJun 28, 2005
  8. Petr BaudisJun 28, 2005
  9. Jan HarkesJun 28, 2005
  10. Christopher LiJun 28, 2005
  11. Linus TorvaldsJun 28, 2005
  12. Emit base objects of a delta chain when the delta is output.Junio C Hamano, Jun 29, 2005
  13. Junio C HamanoJun 28, 2005
  14. Skip writing out sha1 files for objects in packed git.Junio C Hamano, Jun 28, 2005
  15. Linus TorvaldsJun 28, 2005
  16. Junio C HamanoJun 28, 2005
  17. Linus TorvaldsJun 28, 2005
  18. Linus TorvaldsJun 28, 2005
  19. Junio C HamanoJun 28, 2005
  20. Adjust to git-init-db creating $GIT_OBJECT_DIRECTORY/packJunio C Hamano, Jun 28, 2005
  21. Linus TorvaldsJun 28, 2005
  22. Daniel BarkalowJun 28, 2005
  23. Linus TorvaldsJun 28, 2005
  24. Linus TorvaldsJun 28, 2005
  25. Daniel BarkalowJun 28, 2005
  26. Linus TorvaldsJun 28, 2005
  27. Linus TorvaldsJun 28, 2005
  28. Matthias UrlichsJun 28, 2005
  29. Matthias UrlichsJun 28, 2005
  30. Daniel BarkalowJun 28, 2005
  31. Linus TorvaldsJun 29, 2005
  32. Linus TorvaldsJun 29, 2005
  33. Daniel BarkalowJun 29, 2005
  34. Linus TorvaldsJun 29, 2005
  35. Daniel BarkalowJun 29, 2005
  36. Adjust fsck-cache to packed GIT and alternate object pool.Junio C Hamano, Jun 28, 2005
  37. Expose packed_git and alt_odb.Junio C Hamano, Jun 28, 2005
  38. 3/3 Update fsck-cache (take 2)Junio C Hamano, Jun 28, 2005

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.