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

Re: If you would write git from scratch now, what would you change?

From
Nicolas Pitre <nico@cam.org>
Date
Nov 26, 2007, 20:55 UTC
Message-ID
<alpine.LFD.0.99999.0711261529080.9605@xanadu.home>
In-Reply-To
<56b7f5510711261217h56214321xb7acd9851b677dd6@mail.gmail.com>
On Mon, 26 Nov 2007, Dana How wrote:
Show 6 quoted lines
> On Nov 26, 2007 11:52 AM, Nicolas Pitre <nico@cam.org> wrote:
> > On Mon, 26 Nov 2007, Dana How wrote:
> > > Currently data can be quickly copied from pack to pack,
> > > but data cannot be quickly copied blob->pack or pack->blob
> > I don't see why you would need the pack->blob copy normally.
> True,  but that doesn't change the main point.
Sure, but let's not go overboard either.
Show 13 quoted lines
> > > (there was an alternate blob format that supported this,
> > >  but it was deprecated).  Using the pack format for blobs
> > > would fix this.
> >
> > Then you can do just that for big enough blobs where "big enough" is
> > configurable: encapsulate them in a pack instead of a loose object.
> > Problem solved.  Sure you'll end up with a bunch of packs containing
> > only one blob object, but given that those blobs are so large to be a
> > problem in your work flow when written out as loose objects, then they
> > certainly must be few enough not to cause an explosion in the number of
> > packs.
> Are you suggesting that "git add" create a new pack containing
> one blob when the blob is big enough?
Exactly.
> Re-using (part of) the pack format
> in a blob (or maybe only some blobs) seems like less code change.

Don't know what you mean exactly here, but what I mean is to do something as simple as:

	pretend_sha1_file(...);
	add_object_entry(...);
	write_pack_file();

when the buffer to make a blob from is larger than a configured treshold.

Show 8 quoted lines
> > > It would also mean blobs wouldn't need to
> > > be uncompressed to get the blob type or size I believe.
> >
> > They already don't.
> It looks like sha1_file.c:parse_sha1_header() works on a buffer
> filled in by sha1_file.c:unpack_sha1_header() by calling inflate(), right?
> 
> It is true you don't have to uncompress the *entire* blob.
Right.  Only the first 16 bytes or so need to be uncompressed.
Show 17 quoted lines
> > > The equivalent operation in git would require the creation of
> > > the blob,  and then of a temporary pack to send to the server.
> > > This requires 3 calls to zlib for each blob,  which for very
> > > large files is not acceptable at my site.
> >
> > I currently count 2 calls to zlib, not 3.
> I count 3:
> 
> Call 1: git-add calls zlib to make the blob.
> 
> Call 2: builtin-pack-objects.c:write_one() calls sha1_file.c:read_sha1_file()
> calls :unpack_sha1_file() calls :unpack_sha1_{header,rest}() calls
> inflate() to get the data from the blob into a buffer.
> 
> Call 3: Then write_one() calls deflate to make the new buffer
> to write into the pack.  This is all under the "if (!to_reuse) {" path,
> which is active when packing a blob.
Oh, you're right.  Somehow I didn't count the needed decompression.
Show 8 quoted lines
> Remember,  I'm comparing "p4 submit file" to
> "git add file"/"git commit"/"git push",  which is the comparison
> the users will be making.
> 
> On the other hand,  I'm looking at code from June;
> but I haven't noticed big changes since then on the list.
> 
> Calls 2 and 3 go away if the blob and pack formats were more similar.

... which my suggestion should provide with a minimum of changes, maybe less than 10 lines of code.

Nicolas
Previous: Dana HowNext: Dana How
Message 68 of 83 in “If you would write git from scratch now, what would you change?”
  1. Jakub NarebskiNov 25, 2007
  2. Pierre HabouzitNov 25, 2007
  3. Steven WalterNov 26, 2007
  4. Junio C HamanoNov 26, 2007
  5. Adam RobenNov 26, 2007
  6. Carlos RicaNov 26, 2007
  7. Daniel BarkalowNov 26, 2007
  8. Andy ParkinsNov 26, 2007
  9. Benoit SigoureNov 26, 2007
  10. Jan HudecNov 26, 2007
  11. David KastrupNov 26, 2007
  12. Jan HudecNov 26, 2007
  13. Michael PooleNov 26, 2007
  14. Jan HudecNov 26, 2007
  15. Michael PooleNov 26, 2007
  16. Jon SmirlNov 26, 2007
  17. Andy ParkinsNov 26, 2007
  18. Marco CostalbaNov 26, 2007
  19. Shawn O. PearceNov 27, 2007
  20. Jakub NarebskiNov 27, 2007
  21. Shawn O. PearceNov 27, 2007
  22. Johannes SchindelinNov 27, 2007
  23. [RFC] git-gui USer's Survey 2007 (was: If you would write git from scratch now, what would you change?)Jakub Narebski, Nov 27, 2007
  24. Johannes SchindelinNov 28, 2007
  25. Jason SewallNov 28, 2007
  26. Jan HudecNov 28, 2007
  27. Johannes SchindelinNov 28, 2007
  28. Jan HudecNov 29, 2007
  29. Johannes SchindelinNov 29, 2007
  30. Jan HudecNov 30, 2007
  31. Marco CostalbaNov 30, 2007
  32. Shawn O. PearceDec 1, 2007
  33. Marco CostalbaDec 1, 2007
  34. Sergei OrganovNov 28, 2007
  35. Andy ParkinsNov 27, 2007
  36. Marco CostalbaNov 27, 2007
  37. Jan HudecNov 27, 2007
  38. Johannes SchindelinNov 27, 2007
  39. Andy ParkinsDec 4, 2007
  40. Jing XueNov 27, 2007
  41. Jon SmirlNov 26, 2007
  42. David KastrupNov 26, 2007
  43. Jan HudecNov 26, 2007
  44. Benoit SigoureNov 26, 2007
  45. Jan HudecNov 26, 2007
  46. Nicolas PitreNov 26, 2007
  47. David KastrupNov 26, 2007
  48. Jan HudecNov 26, 2007
  49. David KastrupNov 26, 2007
  50. Jan HudecNov 26, 2007
  51. Nicolas PitreNov 26, 2007
  52. Wincent ColaiutaNov 26, 2007
  53. Junio C HamanoNov 26, 2007
  54. Nicolas PitreNov 26, 2007
  55. Junio C HamanoNov 26, 2007
  56. Nicolas PitreNov 26, 2007
  57. Shawn O. PearceNov 27, 2007
  58. Junio C HamanoNov 27, 2007
  59. Steven GrimmNov 27, 2007
  60. Johannes SchindelinNov 26, 2007
  61. Nicolas PitreNov 26, 2007
  62. Johannes SchindelinNov 26, 2007
  63. Andreas EricssonNov 27, 2007
  64. Jakub NarebskiNov 27, 2007
  65. Dana HowNov 26, 2007
  66. Nicolas PitreNov 26, 2007
  67. Dana HowNov 26, 2007
  68. Nicolas PitreNov 26, 2007
  69. Dana HowNov 26, 2007
  70. Nicolas PitreNov 26, 2007
  71. Jakub NarebskiNov 26, 2007
  72. Dana HowNov 26, 2007
  73. Shawn O. PearceNov 27, 2007
  74. Nicolas PitreNov 27, 2007
  75. Shawn O. PearceNov 27, 2007
  76. Junio C HamanoNov 27, 2007
  77. Shawn O. PearceNov 27, 2007
  78. Jakub NarebskiNov 27, 2007
  79. C# binding, was Re: If you would write git from scratch now, what would you change?Johannes Schindelin, Nov 27, 2007
  80. Nicolas PitreNov 27, 2007
  81. Dana HowNov 27, 2007
  82. Shawn O. PearceNov 27, 2007
  83. Linus TorvaldsNov 27, 2007

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.