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

Re: Something is broken in repack

From
Nicolas Pitre <nico@cam.org>
Date
Dec 11, 2007, 17:21 UTC
Message-ID
<alpine.LFD.0.99999.0712111202470.555@xanadu.home>
In-Reply-To
<alpine.LFD.0.9999.0712110806540.25032@woody.linux-foundation.org>
On Tue, 11 Dec 2007, Linus Torvalds wrote:
Show 8 quoted lines
> That said, I suspect there are a few things fighting you:
> 
>  - threading is hard. I haven't looked a lot at the changes Nico did to do 
>    a threaded object packer, but what I've seen does not convince me it is 
>    correct. The "trg_entry" accesses are *mostly* protected with 
>    "cache_lock", but nothing else really seems to be, so quite frankly, I 
>    wouldn't trust the threaded version very much. It's off by default, and 
>    for a good reason, I think.

I beg to differ (of course, since I always know precisely what I do, and like you, my code never has bugs).

Seriously though, the trg_entry has not to be protected at all. Why? Simply because each thread has its own exclusive set of objects which no other threads ever mess with. They never overlap.

Show 13 quoted lines
>    For example: the packing code does this:
> 
> 	if (!src->data) {
> 		read_lock();
> 		src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
> 		read_unlock();
> 		...
> 
>    and that's racy. If two threads come in at roughly the same time and 
>    see a NULL src->data, theÿ́'ll both get the lock, and they'll both 
>    (serially) try to fill it in. It will all *work*, but one of them will 
>    have done unnecessary work, and one of them will have their result 
>    thrown away and leaked.

No. Once again, it is impossible for two threads to ever see the same src->data at all. The lock is there simply because read_sha1_file() is not reentrant.

>    Are you hitting issues like this? I dunno. The object sorting means 
>    that different threads normally shouldn't look at the same objects (not 
>    even the sources), so probably not, but basically, I wouldn't trust the 
>    threading 100%. It needs work, and it needs to stay off by default.

For now it is, but I wouldn't say it really needs significant work at this point. The latest thread patches were more about tuning than correctness.

What the threading could be doing, though, is uncovering some other bugs, like in the pack mmap windowing code for example. Although that code is serialized by the read lock above, the fact that multiple threads are hammering on it in turns means that the mmap window is possibly seeking back and forth much more often than otherwise, possibly leaking something in the process.

Show 17 quoted lines
>  - you're working on a problem that isn't really even worth optimizing 
>    that much. The *normal* case is to re-use old deltas, which makes all 
>    of the issues you are fighting basically go away (because you only have 
>    a few _incremental_ objects that need deltaing). 
> 
>    In other words: the _real_ optimizations have already been done, and 
>    are done elsewhere, and are much smarter (the best way to optimize X is 
>    not to make X run fast, but to avoid doing X in the first place!). The 
>    thing you are trying to work with is the one-time-only case where you 
>    explicitly disable that big and important optimization, and then you 
>    complain about the end result being slow!
> 
>    It's like saying that you're compiling with extreme debugging and no
>    optimizations, and then complaining that the end result doesn't run as 
>    fast as if you used -O2. Except this is a hundred times worse, because 
>    you literally asked git to do the really expensive thing that it really 
>    really doesn't want to do ;)
Linus, please pay attention to the _actual_ important issue here.

Sure I've been tuning the threading code in parallel to the attempt to debug this memory usage issue.

BUT. The point is that repacking the gcc repo using "git repack -a -f --window=250" has a radically different memory usage profile whether you do the repack on the earlier 2.1GB pack or the later 300MB pack. _That_ is the issue. Ironically, it is the 300MB pack that causes the repack to blow memory usage out of proportion.

And in both cases, the threading code has to do the same work whether or not the original pack was densely packed or not since -f throws away every existing deltas anyway.

So something is fishy elsewhere than in the packing code.
Nicolas
Previous: Linus TorvaldsNext: David Miller
Message 70 of 82 in “Something is broken in repack”
  1. Jon SmirlDec 7, 2007
  2. Linus TorvaldsDec 8, 2007
  3. pack-objects: fix delta cache size accountingNicolas Pitre, Dec 8, 2007
  4. Nicolas PitreDec 8, 2007
  5. Jon SmirlDec 8, 2007
  6. Nicolas PitreDec 8, 2007
  7. Jon SmirlDec 8, 2007
  8. David BrownDec 8, 2007
  9. Jon SmirlDec 8, 2007
  10. Nicolas PitreDec 8, 2007
  11. Jon SmirlDec 8, 2007
  12. Nicolas PitreDec 8, 2007
  13. Harvey HarrisonDec 8, 2007
  14. Jon SmirlDec 8, 2007
  15. Harvey HarrisonDec 8, 2007
  16. Junio C HamanoDec 8, 2007
  17. Junio C HamanoDec 9, 2007
  18. Jon SmirlDec 9, 2007
  19. Jon SmirlDec 9, 2007
  20. Nicolas PitreDec 10, 2007
  21. Nicolas PitreDec 10, 2007
  22. David BrownDec 8, 2007
  23. Nicolas PitreDec 10, 2007
  24. Jon SmirlDec 10, 2007
  25. Morten WelinderDec 10, 2007
  26. Jon SmirlDec 11, 2007
  27. Junio C HamanoDec 11, 2007
  28. Nicolas PitreDec 11, 2007
  29. David KastrupDec 11, 2007
  30. Pierre HabouzitDec 11, 2007
  31. David KastrupDec 11, 2007
  32. Nicolas PitreDec 11, 2007
  33. Jon SmirlDec 11, 2007
  34. Jon SmirlDec 11, 2007
  35. Jon SmirlDec 11, 2007
  36. Andreas EricssonDec 11, 2007
  37. Nicolas PitreDec 11, 2007
  38. Nicolas PitreDec 11, 2007
  39. Jon SmirlDec 11, 2007
  40. Nicolas PitreDec 11, 2007
  41. Jon SmirlDec 11, 2007
  42. Nicolas PitreDec 12, 2007
  43. David KastrupDec 12, 2007
  44. Wolfram GlogerDec 14, 2007
  45. Nicolas PitreDec 12, 2007
  46. Paolo BonziniDec 12, 2007
  47. Linus TorvaldsDec 12, 2007
  48. David MillerDec 12, 2007
  49. Linus TorvaldsDec 12, 2007
  50. Jon SmirlDec 12, 2007
  51. Wolfram GlogerDec 14, 2007
  52. David KastrupDec 14, 2007
  53. Wolfram GlogerDec 14, 2007
  54. Nguyen Thai Ngoc DuyDec 13, 2007
  55. Paolo BonziniDec 13, 2007
  56. Paolo BonziniDec 13, 2007
  57. Johannes SixtDec 13, 2007
  58. Jakub NarebskiDec 14, 2007
  59. Paolo BonziniDec 14, 2007
  60. Nguyen Thai Ngoc DuyDec 14, 2007
  61. Paolo BonziniDec 14, 2007
  62. Harvey HarrisonDec 14, 2007
  63. Jakub NarebskiDec 14, 2007
  64. Nguyen Thai Ngoc DuyDec 14, 2007
  65. Nicolas PitreDec 14, 2007
  66. Nicolas PitreDec 12, 2007
  67. Andreas EricssonDec 13, 2007
  68. Wolfram GlogerDec 14, 2007
  69. Linus TorvaldsDec 11, 2007
  70. Nicolas PitreDec 11, 2007
  71. David MillerDec 11, 2007
  72. Nicolas PitreDec 11, 2007
  73. Andreas EricssonDec 11, 2007
  74. Jon SmirlDec 11, 2007
  75. Nicolas PitreDec 11, 2007
  76. Linus TorvaldsDec 11, 2007
  77. Junio C HamanoDec 11, 2007
  78. Andreas EricssonDec 11, 2007
  79. Daniel BerlinDec 11, 2007
  80. Nicolas PitreDec 11, 2007
  81. SeanDec 11, 2007
  82. Jon SmirlDec 11, 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.