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

Re: FFmpeg considering GIT

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 6, 2007, 16:38 UTC
Message-ID
<alpine.LFD.0.98.0705060919010.25245@woody.linux-foundation.org>
In-Reply-To
<20070506101953.GA17498@diana.vm.bytemark.co.uk>
On Sun, 6 May 2007, Karl Hasselstr?m wrote:
Show 13 quoted lines
> 
> OK, now I've tested it, and just as you said, it works (and is _very_
> useful) but looks like crap. :-)
> 
> Is there any fundamental reason why
> 
>   gitk -- some/path/name
> 
> generates a nice, connected graph, while
> 
>   gitk -S'some string'
> 
> generates disconnected spaghetti?

There is a reason, and it's fairly fundamental: the path limiting code is deeply embedded in the revision walking, and I've spent a fair amount of effort on making that work and efficient as hell (it's one of the few areas in git where I'm probably still the main author). Because it's literally what I do 90% of the time: for me, the path-limiting code is basically _the_ most important git feature, and I care very deeply.

In contrast, the "-S" thing is not actually part of the revision walking at all, and is a totally separate phase that is done when revisions are _shown_. I almost never use it myself, and it grew out of a totally separate effort by Junio.

> Or could the latter be made to use the same parent-rewriting logic as 
> the first?

It would probably be possible to make the -S logic be another part of the "prune_fn()" logic in revision.c, and it might even simplify some of the logic, but I suspect it would actually suck really really badly from a performance standpoint.

Why? Because the prune_fn() logic is done when we generate the revision graph, which is generally something that a lot of the operations have to do up-front before they can do _anything_ else. Eg, any revision limiter (and that's a very common case) like "v2.6.21.." will cause the revision pruning to happen synchronously and early on.

And the path-limiting is *fast*. It's so incredibly fast that people don't really realize how fast it is. And it absolutely needs to be fast, because when you do something like "gitk v2.6.18.. drivers/" on the kernel you end up doing a _lot_ of tree comparisons. It's why I'm pretty sure nobody else can ever do what git does - it takes full advantage of how git can tell that a whole subdirectory hasn't changed without even recursing into it.

In contrast, "-S" is _slow_. It's a really really expensive operation. Git makes generating diffs faster than just about anything else, but it's still really expensive. This is a really unfair comparison, but:

	time git log drivers/net/ > /dev/null
	real    0m1.488s
	user    0m1.444s
	sys     0m0.040s

ie we can do the log pruning for the whole kernel git history on a subdirectory in less than two seconds.

Try to compare it with
	time git log -Sdrivers/net/ > /dev/null
and I suspect you won't have the patience to wait for the end result.

And yeah, the operations are fundamentally very very different, and yes, the latter operation is really really expensive (which is why I said it's a really unfair comparison). But the point is that the expense comes from how git has been designed: seeing differences in the paths is cheap by design (it's how the data structures are laid out), but seeing differences in actual diffs means that we have to fully generate each diff for each revision!

A different approach to the underlying datastructures could change the equation. For example, if the fundamental data representation was the "diff" (rather than the "whole tree") maybe -S would be as fast as path limiting. But you'd *really* suck for other things.

To summarize a long story: the path limiting is simply more fundamental in git. Both by design, and then - obviously partly _due_ to that - by pure effort we've spent on it. It's something very deep and very important. In comparison, the -S thing is a cute extra feature, nothing really "deep".

		Linus
Previous: Karl HasselströmNext: Marco Costalba
Message 57 of 66 in “FFmpeg considering GIT”
  1. Panagiotis IssarisMay 2, 2007
  2. Jakub NarebskiMay 2, 2007
  3. Petr BaudisMay 3, 2007
  4. Jakub NarebskiMay 4, 2007
  5. [RFC?] Telling git about more complex relationships between commits (Was: Re: FFmpeg considering GIT)Johan Herland, May 4, 2007
  6. Alex RiesenMay 4, 2007
  7. Andy ParkinsMay 4, 2007
  8. Andrew RuderMay 4, 2007
  9. Johan HerlandMay 4, 2007
  10. Johan HerlandMay 4, 2007
  11. Alex RiesenMay 4, 2007
  12. Johan HerlandMay 5, 2007
  13. Alex RiesenMay 5, 2007
  14. Johan HerlandMay 5, 2007
  15. Petr BaudisMay 4, 2007
  16. Johan HerlandMay 4, 2007
  17. Martin LanghoffMay 3, 2007
  18. Uwe Kleine-KönigMay 3, 2007
  19. Petr BaudisMay 3, 2007
  20. david@lang.hmMay 3, 2007
  21. Petr BaudisMay 3, 2007
  22. Michael NiedermayerMay 4, 2007
  23. Andy ParkinsMay 4, 2007
  24. Johannes SixtMay 4, 2007
  25. Florian WeimerMay 4, 2007
  26. Nicolas PitreMay 4, 2007
  27. Carl WorthMay 4, 2007
  28. Johan HerlandMay 4, 2007
  29. Michael NiedermayerMay 4, 2007
  30. Linus TorvaldsMay 5, 2007
  31. Karl HasselströmMay 5, 2007
  32. Linus TorvaldsMay 5, 2007
  33. Linus TorvaldsMay 5, 2007
  34. Linus TorvaldsMay 5, 2007
  35. Junio C HamanoMay 6, 2007
  36. Paul MackerrasMay 7, 2007
  37. Karl HasselströmMay 7, 2007
  38. Johan HerlandMay 7, 2007
  39. Alex RiesenMay 7, 2007
  40. Marco CostalbaMay 8, 2007
  41. Paul MackerrasMay 9, 2007
  42. Marco CostalbaMay 9, 2007
  43. Robin RosenbergMay 9, 2007
  44. Jan HudecMay 9, 2007
  45. Fredrik KuivinenMay 9, 2007
  46. Jan HudecMay 9, 2007
  47. Marco CostalbaMay 10, 2007
  48. Jan HudecMay 10, 2007
  49. Jan HudecMay 7, 2007
  50. Gábor FarkasMay 7, 2007
  51. Randal L. SchwartzMay 7, 2007
  52. Junio C HamanoMay 7, 2007
  53. Shawn O. PearceMay 8, 2007
  54. Jeff KingMay 8, 2007
  55. Karl HasselströmMay 6, 2007
  56. Karl HasselströmMay 6, 2007
  57. Linus TorvaldsMay 6, 2007
  58. Marco CostalbaMay 6, 2007
  59. Karl HasselströmMay 6, 2007
  60. Marco CostalbaMay 6, 2007
  61. Karl HasselströmMay 6, 2007
  62. Marco CostalbaMay 6, 2007
  63. Karl HasselströmMay 6, 2007
  64. Karl HasselströmMay 6, 2007
  65. Pavel RoskinMay 9, 2007
  66. Gábor FarkasMay 8, 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.