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

Re: Performance issue of 'git branch'

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 23, 2009, 02:20 UTC
Message-ID
<alpine.LFD.2.01.0907221850000.3352@localhost.localdomain>
In-Reply-To
<20090723012207.GA9368@Pilar.aei.mpg.de>
On Thu, 23 Jul 2009, Carlos R. Mafra wrote:
Show 5 quoted lines
> > Let me guess: if you do a "ls -ld .git/refs/heads" you get a very big 
> > directory, despite it only having three entries in it. 
> 
> [mafra@Pilar:linux-2.6]$ ls -ld .git/refs/heads
> drwxr-xr-x 2 mafra mafra 4096 2009-07-22 23:01 .git/refs/heads/
Hmm. That's just a single block. 
Then I really don't see why the lstat takes so long.
Show 7 quoted lines
> After 'echo 3 > /proc/sys/vm/drop_caches' it still takes too long,
> 
> 1248310449.693085 munmap(0x7f50bcd11000, 164) = 0
> 1248310449.693187 lstat(".git/refs/heads/sparse", 0x7fff618c0960) = -1 ENOENT (No such file or directory)
> 1248310449.719112 lstat(".git/refs/heads/stern", 0x7fff618c0960) = -1 ENOENT (No such file or directory)
> 1248310453.014041 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
> 1248310453.014183 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f50bcd11000

Use 'strace -T', which shows how long the actual system calls take, rather than '-tt' which just shows when they started.

Maybe the four seconds is something else than the lstat - page faults on the pack-file in between the lstat and the fstat, for example.

> Perhaps I should delete the "stern" branch, but I would like to learn why
> it is slowing things, because it also happened before (in fact it is always
> like this, afaicr)
Absolutely. Don't delete it until we figure out what takes so long there.
> Do you have another theory? (now .git/refs/heads is empty)

Clearly it's IO, but if that 'lstat()' was just a red herring, then I suspect it's IO on the pack-file. If so, I'd further guess that your VAIO has some pitiful 4200rpm harddisk that is slow as hell and has horrible seek latencies, and the CPU is way overpowered compared to the cruddy disk.

It probably does the object lookup. You can see some debug output if you do

	GIT_DEBUG_LOOKUP=1 git branch

and that will show you the patterns. It won't be very pretty, especially if you have several pack-files, but maybe we can figure out what's up.

Hmm. I wonder.. I suspect 'git branch' looks up _all_ refs, and then afterwards it filters them. So even though it only prints out a few branches, maybe it will look at all the tags etc of the whole repository.

Ooh yes. That would do it. It's going to peel and look up every single ref it finds, so it's going to look up _hundreds_ of objects (all the tags, all the commits they point to, etc etc). Even if it then only shows a couple of branches.

Junio, any ideas?
		Linus
Previous: Carlos R. MafraNext: Linus Torvalds
Message 11 of 73 in “Performance issue of 'git branch'”
  1. Carlos R. MafraJul 22, 2009
  2. Linus TorvaldsJul 23, 2009
  3. Linus TorvaldsJul 23, 2009
  4. Linus TorvaldsJul 23, 2009
  5. Carlos R. MafraJul 23, 2009
  6. Linus TorvaldsJul 23, 2009
  7. Jakub NarebskiJul 23, 2009
  8. Carlos R. MafraJul 23, 2009
  9. Linus TorvaldsJul 23, 2009
  10. Carlos R. MafraJul 23, 2009
  11. Linus TorvaldsJul 23, 2009
  12. Linus TorvaldsJul 23, 2009
  13. Linus TorvaldsJul 23, 2009
  14. Linus TorvaldsJul 23, 2009
  15. Tony FinchJul 23, 2009
  16. Linus TorvaldsJul 23, 2009
  17. Newton-Raphson, was Re: Performance issue of 'git branch'Tony Finch, Jul 23, 2009
  18. Johannes SchindelinJul 23, 2009
  19. Tony FinchJul 23, 2009
  20. Johannes SchindelinJul 24, 2009
  21. Carlos R. MafraJul 23, 2009
  22. Carlos R. MafraJul 23, 2009
  23. Carlos R. MafraJul 23, 2009
  24. Linus TorvaldsJul 23, 2009
  25. Linus TorvaldsJul 23, 2009
  26. Junio C HamanoJul 23, 2009
  27. Carlos R. MafraJul 23, 2009
  28. Junio C HamanoJul 23, 2009
  29. Linus TorvaldsJul 23, 2009
  30. Junio C HamanoJul 23, 2009
  31. Junio C HamanoJul 23, 2009
  32. Linus TorvaldsJul 23, 2009
  33. Carlos R. MafraJul 23, 2009
  34. Linus TorvaldsJul 23, 2009
  35. Carlos R. MafraJul 23, 2009
  36. Linus TorvaldsJul 23, 2009
  37. Linus TorvaldsJul 23, 2009
  38. Carlos R. MafraJul 23, 2009
  39. Linus TorvaldsJul 24, 2009
  40. Linus TorvaldsJul 24, 2009
  41. Linus TorvaldsJul 24, 2009
  42. Linus TorvaldsJul 24, 2009
  43. david@lang.hmJul 24, 2009
  44. Linus TorvaldsJul 24, 2009
  45. david@lang.hmJul 24, 2009
  46. Linus TorvaldsJul 25, 2009
  47. Daniel BarkalowJul 25, 2009
  48. Jeff KingAug 7, 2009
  49. Theodore TsoJul 24, 2009
  50. Shawn O. PearceJul 24, 2009
  51. Junio C HamanoJul 24, 2009
  52. Avi KivityJul 26, 2009
  53. Johannes SchindelinJul 26, 2009
  54. Carlos R. MafraJul 24, 2009
  55. Carlos R. MafraJul 25, 2009
  56. Linus TorvaldsJul 25, 2009
  57. Timo HirvonenJul 25, 2009
  58. Reece DunnJul 25, 2009
  59. Mike HommeyJul 25, 2009
  60. Linus TorvaldsJul 25, 2009
  61. Linus TorvaldsJul 25, 2009
  62. Johannes SchindelinJul 25, 2009
  63. Linus TorvaldsJul 26, 2009
  64. Theodore TsoJul 26, 2009
  65. Mike HommeyJul 26, 2009
  66. Johannes SchindelinJul 26, 2009
  67. demerphqJul 26, 2009
  68. demerphqJul 26, 2009
  69. Carlos R. MafraJul 25, 2009
  70. Anders KaseorgJul 23, 2009
  71. Carlos R. MafraJul 23, 2009
  72. SZEDER GáborJul 23, 2009
  73. Carlos R. MafraJul 23, 2009

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.