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

Re: [Gnu-arch-users] Re: [GNU-arch-dev] [ANNOUNCEMENT] /Arch/ embraces `git'

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 22, 2005, 16:13 UTC
Message-ID
<Pine.LNX.4.58.0504220844390.2344@ppc970.osdl.org>
In-Reply-To
<1114069758.5886.9.camel@perun.redhat.usu>
On Thu, 21 Apr 2005, Tomas Mraz wrote:
> 
> However you're right that the original structure proposed by Linus is
> too flat.
You're wrong. 

The thing is, having 256 sybdirectories already eats one _megabyte_ of diskspace on common filessystems. If you expand that to be either deeper (ie subdirectories within subdirectories), or use more than 8 bits for the first level, you'll be using much more.

A megabyte of diskspace is peanuts for a project like Linux, but I think it matters for small projects. I want git to work reasonably even for really trivial stuff.

For example, if you just expand the fan-out to use 12 bits instead of 8, you're now using 16MB of diskspace just for the directory structure, even for a trivially small project. I just think that sucks.

Secondly, any sane OS (and filesystem) will look up flat directories _faster_ than deep directories. Peter Anvid did the testing: a _totally_ flat directory is actually the best-performing one.

I just don't want to go there, because while it's ok to have tens of thousands of files in one subdirectory, I don't think it's ok to have hundreds of thousands of files. The 8-bit initial fan-out is very much a middle ground: we waste some space (and some time) doing it, but it does make the really horrible case largely go away.

Trust me, the design of git didn't just come out of my *ss. Unlike pretty much apparently any other SCM engineer in the history of mankind (judging by the performance crap that is out there), I actually know what performs well, and I can calculate how much space we waste, and I actually _did_ do so, and chose a reasonably intelligent middle ground.

You can bicker about the details (should it be 9 bits? should we pack the names more densely? should we use another algorithm for compression? why does it bother to use ASCII headers?), but please realize that those are _details_. And even then, they are details where I bet that I have selected pretty reasonable initial values.

So my choices may not be optimal, but they are "reasonable across a wide variety of different parameters". And that includes project size, filesystem implementation, disk wastage etc etc.

The only "extreme" choice I actually made was to go with the highest compression level of zlib. I think I made the right choice there too: it wastes CPU-time, but it's still pretty cheap(*) and keeps getting cheaper. And we have a much higher read-to-write ratio that most other systems have.

(*) I'll also argue that one reason even "-9" is cheap is actually that most of the files we compress are small. All the metadata files are really quite small, and most source-files tend to be just a few kB in size too - I personally believe that _big_ files tend to be things that really change quite seldom (things with big tables like firmware files etc). And for a small file, it doesn't actually matter that much, the compression window just can't grow too much.

So people say that "gzip -9" is expensive, but it's really expensive only for large files. Try it out, it's just a personal pet theory of mine. But realize that I _do_ generally think things through. I don't just cobble together random things. There's a real _reason_ why git runs like a bat out of hell. It was _designed_.

			Linus
Previous: Tom LordNext: Edésio Costa e Silva
Message 17 of 23 in “[ANNOUNCEMENT] /Arch/ embraces `git'”
  1. Tom LordApr 20, 2005
  2. Miles BaderApr 20, 2005
  3. duchier@ps.uni-sb.deApr 20, 2005
  4. Tomas MrazApr 20, 2005
  5. Denys DuchierApr 21, 2005
  6. Tomas MrazApr 21, 2005
  7. duchier@ps.uni-sb.deApr 21, 2005
  8. Tomas MrazApr 20, 2005
  9. Tom LordApr 21, 2005
  10. Tom LordApr 21, 2005
  11. Tom LordApr 20, 2005
  12. Denys DuchierApr 21, 2005
  13. Tom LordApr 21, 2005
  14. Tomas MrazApr 21, 2005
  15. Tom LordApr 21, 2005
  16. Tom LordApr 21, 2005
  17. Linus TorvaldsApr 22, 2005
  18. Edésio Costa e SilvaApr 22, 2005
  19. Petr BaudisApr 20, 2005
  20. C. Scott AnanianApr 20, 2005
  21. chunking (Re: [ANNOUNCEMENT] /Arch/ embraces `git')Linus Torvalds, Apr 20, 2005
  22. C. Scott AnanianApr 20, 2005
  23. blowing chunks (quick update)C. Scott Ananian, Apr 22, 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.