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

Re: Git and GCC

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Dec 6, 2007, 06:09 UTC
Message-ID
<alpine.LFD.0.9999.0712052132450.13796@woody.linux-foundation.org>
In-Reply-To
<4aca3dc20712052111o730f6fb6h7a329ee811a70f28@mail.gmail.com>
On Thu, 6 Dec 2007, Daniel Berlin wrote:
> 
> Actually, it turns out that git-gc --aggressive does this dumb thing
> to pack files sometimes regardless of whether you converted from an
> SVN repo or not.

Absolutely. git --aggressive is mostly dumb. It's really only useful for the case of "I know I have a *really* bad pack, and I want to throw away all the bad packing decisions I have done".

To explain this, it's worth explaining (you are probably aware of it, but let me go through the basics anyway) how git delta-chains work, and how they are so different from most other systems.

In other SCM's, a delta-chain is generally fixed. It might be "forwards" or "backwards", and it might evolve a bit as you work with the repository, but generally it's a chain of changes to a single file represented as some kind of single SCM entity. In CVS, it's obviously the *,v file, and a lot of other systems do rather similar things.

Git also does delta-chains, but it does them a lot more "loosely". There is no fixed entity. Delta's are generated against any random other version that git deems to be a good delta candidate (with various fairly successful heursitics), and there are absolutely no hard grouping rules.

This is generally a very good thing. It's good for various conceptual reasons (ie git internally never really even needs to care about the whole revision chain - it doesn't really think in terms of deltas at all), but it's also great because getting rid of the inflexible delta rules means that git doesn't have any problems at all with merging two files together, for example - there simply are no arbitrary *,v "revision files" that have some hidden meaning.

It also means that the choice of deltas is a much more open-ended question. If you limit the delta chain to just one file, you really don't have a lot of choices on what to do about deltas, but in git, it really can be a totally different issue.

And this is where the really badly named "--aggressive" comes in. While git generally tries to re-use delta information (because it's a good idea, and it doesn't waste CPU time re-finding all the good deltas we found earlier), sometimes you want to say "let's start all over, with a blank slate, and ignore all the previous delta information, and try to generate a new set of deltas".

So "--aggressive" is not really about being aggressive, but about wasting CPU time re-doing a decision we already did earlier!

*Sometimes* that is a good thing. Some import tools in particular could generate really horribly bad deltas. Anything that uses "git fast-import", for example, likely doesn't have much of a great delta layout, so it might be worth saying "I want to start from a clean slate".

But almost always, in other cases, it's actually a really bad thing to do. It's going to waste CPU time, and especially if you had actually done a good job at deltaing earlier, the end result isn't going to re-use all those *good* deltas you already found, so you'll actually end up with a much worse end result too!

I'll send a patch to Junio to just remove the "git gc --aggressive" documentation. It can be useful, but it generally is useful only when you really understand at a very deep level what it's doing, and that documentation doesn't help you do that.

Generally, doing incremental "git gc" is the right approach, and better than doing "git gc --aggressive". It's going to re-use old deltas, and when those old deltas can't be found (the reason for doing incremental GC in the first place!) it's going to create new ones.

On the other hand, it's definitely true that an "initial import of a long and involved history" is a point where it can be worth spending a lot of time finding the *really*good* deltas. Then, every user ever after (as long as they don't use "git gc --aggressive" to undo it!) will get the advantage of that one-time event. So especially for big projects with a long history, it's probably worth doing some extra work, telling the delta finding code to go wild.

So the equivalent of "git gc --aggressive" - but done *properly* - is to do (overnight) something like

	git repack -a -d --depth=250 --window=250

where that depth thing is just about how deep the delta chains can be (make them longer for old history - it's worth the space overhead), and the window thing is about how big an object window we want each delta candidate to scan.

And here, you might well want to add the "-f" flag (which is the "drop all old deltas", since you now are actually trying to make sure that this one actually finds good candidates.

And then it's going to take forever and a day (ie a "do it overnight" thing). But the end result is that everybody downstream from that repository will get much better packs, without having to spend any effort on it themselves.

			Linus
Previous: David MillerNext: Harvey Harrison
Message 45 of 89 in “Re: Git and GCC”
  1. David MillerDec 6, 2007
  2. Daniel BerlinDec 6, 2007
  3. David MillerDec 6, 2007
  4. Daniel BerlinDec 6, 2007
  5. David MillerDec 6, 2007
  6. Harvey HarrisonDec 6, 2007
  7. Daniel BerlinDec 6, 2007
  8. David MillerDec 6, 2007
  9. Daniel BerlinDec 6, 2007
  10. Harvey HarrisonDec 6, 2007
  11. Daniel BerlinDec 6, 2007
  12. Jon SmirlDec 6, 2007
  13. Jeff KingDec 6, 2007
  14. Nicolas PitreDec 6, 2007
  15. Jeff KingDec 6, 2007
  16. Nicolas PitreDec 6, 2007
  17. Jeff KingDec 7, 2007
  18. Jeff KingDec 7, 2007
  19. Linus TorvaldsDec 6, 2007
  20. Jon SmirlDec 6, 2007
  21. Nicolas PitreDec 6, 2007
  22. Jon SmirlDec 6, 2007
  23. Nicolas PitreDec 6, 2007
  24. Jon SmirlDec 6, 2007
  25. Jon SmirlDec 6, 2007
  26. Nicolas PitreDec 6, 2007
  27. Jon SmirlDec 6, 2007
  28. Jeff KingDec 7, 2007
  29. Harvey HarrisonDec 8, 2007
  30. Gabriel PaubertDec 10, 2007
  31. Nicolas PitreDec 10, 2007
  32. David MillerDec 7, 2007
  33. Jeff KingDec 7, 2007
  34. Jon SmirlDec 7, 2007
  35. David MillerDec 7, 2007
  36. Linus TorvaldsDec 7, 2007
  37. Giovanni BajoDec 7, 2007
  38. Jakub NarebskiDec 7, 2007
  39. Luke LuDec 7, 2007
  40. Giovanni BajoDec 7, 2007
  41. Daniel BerlinDec 7, 2007
  42. Johannes SchindelinDec 8, 2007
  43. David MillerDec 8, 2007
  44. David MillerDec 10, 2007
  45. Linus TorvaldsDec 6, 2007
  46. Harvey HarrisonDec 6, 2007
  47. David BrownDec 6, 2007
  48. Nicolas PitreDec 6, 2007
  49. gc --aggressive: make it really aggressiveJohannes Schindelin, Dec 6, 2007
  50. Theodore TsoDec 6, 2007
  51. Nicolas PitreDec 6, 2007
  52. Pierre HabouzitDec 6, 2007
  53. Johannes SchindelinDec 6, 2007
  54. David KastrupDec 6, 2007
  55. Harvey HarrisonDec 6, 2007
  56. Johannes SchindelinDec 6, 2007
  57. Linus TorvaldsDec 6, 2007
  58. Johannes SchindelinMar 18, 2009
  59. Teemu LikonenMar 18, 2009
  60. Nicolas PitreMar 18, 2009
  61. Daniel BerlinDec 6, 2007
  62. Linus TorvaldsDec 6, 2007
  63. Harvey HarrisonDec 7, 2007
  64. Linus TorvaldsDec 7, 2007
  65. Jon SmirlDec 7, 2007
  66. Nicolas PitreDec 7, 2007
  67. Linus TorvaldsDec 7, 2007
  68. Jon SmirlDec 7, 2007
  69. Nicolas PitreDec 7, 2007
  70. NightStrikeDec 6, 2007
  71. Linus TorvaldsDec 6, 2007
  72. NightStrikeDec 7, 2007
  73. Jon LoeligerDec 6, 2007
  74. Linus TorvaldsDec 6, 2007
  75. Jakub NarebskiDec 7, 2007
  76. Junio C HamanoDec 6, 2007
  77. Junio C HamanoDec 6, 2007
  78. David KastrupDec 6, 2007
  79. [OT] Re: Git and GCCRandy Dunlap, Dec 6, 2007
  80. Harvey HarrisonDec 6, 2007
  81. Linus TorvaldsDec 6, 2007
  82. Harvey HarrisonDec 6, 2007
  83. Johannes SchindelinDec 6, 2007
  84. Ismail DönmezDec 6, 2007
  85. "Argument list too long" in git remote update (Was: Git and GCC)Geert Bosch, Dec 17, 2007
  86. Johannes SchindelinDec 17, 2007
  87. Linus TorvaldsDec 17, 2007
  88. Derek FawcusDec 18, 2007
  89. Shawn O. PearceDec 18, 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.