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

[PATCH 0/2] History replay support

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Nov 2, 2007, 20:31 UTC
Message-ID
<alpine.LFD.0.999.0711021301200.3342@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.0.999.0711021114390.3342@woody.linux-foundation.org>

Ok, this is a rough first draft of avoiding the topological sort up-front, and instead incrementally sorting only when actually necessary.

The first patch is a pure cleanup. Quite frankly, I suspect the old topological sorting code would have worked perfectly fine as-is, but I couldn't really bear to watch it or think about debugging it the way it was before.

The indirection and other strangeness just blew my tiny little mind, and while I bet it had some historical reason, I ended up reworking that thing. I tried to keep it as similar as humanly possible to the old code (because it's easy to get wrong, and because I really didn't want to worry about the toposort itself), but the numbers speak for themselves:

	 4 files changed, 55 insertions(+), 126 deletions(-)

should tell you something. And it means that there are no subtle calling issues with preconditions for using the toposort etc - you can use it over and over again, and it should all be obvious. Knock wood.

The second diff is the one that actually adds the new feature, and it undoes most of the nice statistics of the first one:

	 5 files changed, 70 insertions(+), 12 deletions(-)

but we still end up with more deletions than insertions on the whole, *and* a new feature.

The new code is triggered by using the "--replay" flag, which will cause certain consistency checks to be done when a commit is shown by the log machinery. In particular:

 - if we print out a parent SHA1, and the parent has already been shown, 
   that's a topology violation, and causes a replay.
 - if we turn a commit unintersting, and the commit has already been 
   shown, that's a "uninteresting" violation, and causes a replay.

The second one I didn't test at all. It's probably hard to trigger, and I bet there are bugs there, but this is very much a WIP patch, with the hope that people other than me can work on it.

When a replay happens, the log code will print out
	Replay <sha1>

for each <sha1> commit that gets invalidated by the replay, and then start *that* part of history anew, with just the required part re-sorted.

Should it print just the number of commits? Perhaps. Play around with this.

Anyway, to give you some kind of idea of the effect of this, in the current git tree as it exists in my repo, I get 15 replay events, and if you compare the total log output, you see:

	[torvalds@woody git]$ wc -l t1 t2
	  170191 t1
	  178150 t2

where "t1" is without replays, and "t2" is with replays. The replays obviously do add lines (the replayed ones), but at least for git, it's on the order of 5% lines replayed.

The big difference is in the latency:
	time git log --parents --topo-order | head
	real    0m0.163s
vs
	time git log --parents --replay | head
	real    0m0.003s

ie you can see how the --replay thing starts outputtig commits immediately, because it knows it can just back up and fix any errors that happen.

That's the good news.

The bad news is that it doesn't work well in this simplistic form, because there is a O(n**2) behaviour when replays *do* happen, ie we end up having replays within replays, and rather than getting a 5% increase like for git itself, for the kernel archive this gets a roughly 50x increase for the replay. So the *latency* still improves dramatically (getting the first one hundred commits in 0.006 seconds vs 1.076s), but because of the bad behaviour wrt cascading replays, it's not really usable in this form (the full log goes from 8 seconds to 22s when writing to /dev/null - and is much worse if the receiver actually has to do something about it).

I think the right thing to do wrt this all would be to turn the replay logic into a latency-based one, where it would basically batch things up, but make sure to output something at least every half a second or so. But that's a pretty separate set of logic, so I thought I'd send this out as-is for comments..

			Linus
Previous: Linus TorvaldsNext: Linus Torvalds
Message 13 of 57 in “New features in gitk”
  1. Paul MackerrasOct 28, 2007
  2. Linus TorvaldsOct 28, 2007
  3. Paul MackerrasOct 28, 2007
  4. Steffen ProhaskaOct 28, 2007
  5. Linus TorvaldsOct 28, 2007
  6. Paul MackerrasNov 1, 2007
  7. Linus TorvaldsNov 1, 2007
  8. Paul MackerrasNov 2, 2007
  9. Marco CostalbaNov 2, 2007
  10. Linus TorvaldsNov 2, 2007
  11. Marco CostalbaNov 2, 2007
  12. Linus TorvaldsNov 2, 2007
  13. 0/2 History replay supportLinus Torvalds, Nov 2, 2007
  14. 1/2 Simplify topo-sort logicLinus Torvalds, Nov 2, 2007
  15. 2/2 Support "history replay" for git log commandsLinus Torvalds, Nov 2, 2007
  16. Junio C HamanoNov 2, 2007
  17. Linus TorvaldsNov 2, 2007
  18. Linus TorvaldsNov 3, 2007
  19. Marco CostalbaNov 3, 2007
  20. 2/2 Add "--early-output" log flag for interactive GUI useLinus Torvalds, Nov 3, 2007
  21. Marco CostalbaNov 3, 2007
  22. Paul MackerrasNov 4, 2007
  23. Linus TorvaldsNov 4, 2007
  24. Paul MackerrasNov 4, 2007
  25. Marco CostalbaNov 4, 2007
  26. Linus TorvaldsNov 4, 2007
  27. 3/2 Enhance --early-output formatLinus Torvalds, Nov 4, 2007
  28. Junio C HamanoNov 5, 2007
  29. Linus TorvaldsNov 5, 2007
  30. Linus TorvaldsNov 5, 2007
  31. Linus TorvaldsNov 5, 2007
  32. 4/2 Fix parent rewriting in --early-outputLinus Torvalds, Nov 13, 2007
  33. Junio C HamanoNov 13, 2007
  34. Linus TorvaldsNov 13, 2007
  35. Linus TorvaldsNov 13, 2007
  36. Sven VerdoolaegeNov 13, 2007
  37. Junio C HamanoNov 13, 2007
  38. Shawn O. PearceNov 13, 2007
  39. Junio C HamanoNov 13, 2007
  40. Paul MackerrasNov 13, 2007
  41. Junio C HamanoNov 13, 2007
  42. Paul MackerrasNov 13, 2007
  43. Marco CostalbaNov 16, 2007
  44. Paul MackerrasNov 4, 2007
  45. Johannes SchindelinNov 2, 2007
  46. Linus TorvaldsNov 2, 2007
  47. Paul MackerrasNov 1, 2007
  48. Linus TorvaldsNov 1, 2007
  49. Linus TorvaldsNov 1, 2007
  50. Pierre HabouzitOct 28, 2007
  51. Mike HommeyOct 28, 2007
  52. Paul MackerrasOct 28, 2007
  53. Pierre HabouzitOct 29, 2007
  54. Jonathan del StrotherOct 29, 2007
  55. Pierre HabouzitOct 29, 2007
  56. Han-Wen NienhuysOct 29, 2007
  57. Michele BallabioOct 29, 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.