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

Re: Unreliable 'git rebase --onto'

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Jan 9, 2020, 15:03 UTC
Message-ID
<20200109150332.GF32750@szeder.dev>
In-Reply-To
<CABPp-BHsy75UGm4wTOP2_AYik_dZi-_BxtAn-hyi-ZrNRRWGuw@mail.gmail.com>
On Wed, Jan 08, 2020 at 04:55:46PM -0800, Elijah Newren wrote:
Show 5 quoted lines
> > Alas, there is unexpected bad news: with that commit the runtime of
> > your 'git rebase --onto' command goes from <1sec to over 50secs.
> > Cc-ing Elijah, author of that patch...
> 
> I see slowdown, but not nearly as big as you report:
The linux repo is big, my notebook is small, the poor thing :)
Show 9 quoted lines
> $ time git rebase -m --onto v4.18 463fa44eec2fef50~ 463fa44eec2fef50
> warning: inexact rename detection was skipped due to too many files.
> warning: you may want to set your merge.renamelimit variable to at
> least 7216 and retry the command.
> Successfully rebased and updated detached HEAD.
> 
> real 0m13.305s
> user 0m9.644s
> sys 0m3.620s
Show 12 quoted lines
> Interestingly, turning off rename detection only speeds it up a little bit:
> $ time git rebase -m -Xno-renames --onto v4.18 463fa44eec2fef50~
> 463fa44eec2fef50
> Successfully rebased and updated detached HEAD.
> 
> real 0m11.955s
> user 0m8.732s
> sys 0m3.424s
> 
> 
> This is an interesting testcase; I'm going to try to find some time to
> dig in further.
The culprits are two seemingly unnecessary back-and-forth checkouts.

I didn't realize I could use 'git rebase -m', so ran some tests with it, and turns out that the slowdown started with 68aa495b59 (rebase: implement --merge via the interactive machinery, 2018-12-11), where the runtime suddenly went from <1.5s to 45+s.

Running 'git rebase -i --onto <those-same-commits>' is just as slow, and it appears that it has always been (the oldest I tried was v1.8.0), and it spends a long time both before and after popping up the editor for the rebase instructions. That's highly suspicious, so:

  $ git log --oneline -1
  94710cac0ef4 (HEAD, tag: v4.18) Linux 4.18
  $ git rebase -i --onto v4.18 463fa44eec2fef50~ 463fa44eec2fef50
  hint: Waiting for your editor to close the file... 
  # Hit ctrl-z in the editor
  $ git log --oneline -1
  463fa44eec2f (HEAD) Input: atmel_mxt_ts - disable IRQ across suspend
Oh.

So 'git rebase -i' apparently checks out the tip commit of the to-be-rebased revision range before invoking the editor for the rebase instructions, only to check out the --onto commit (i.e. the commit we've started from!) to apply the selected commit on top.

And indeed those two checkouts account for all the wasted runtime:
  $ time { git checkout 463fa44eec2fef50 && git checkout v4.18 ; }
  Updating files: 100% (49483/49483), done.
  Previous HEAD position was 94710cac0ef4 Linux 4.18
  HEAD is now at 463fa44eec2f Input: atmel_mxt_ts - disable IRQ across suspend
  Updating files: 100% (49483/49483), done.
  Previous HEAD position was 463fa44eec2f Input: atmel_mxt_ts - disable IRQ across suspend
  HEAD is now at 94710cac0ef4 Linux 4.18
  
  real    0m48.801s
  user    0m13.963s
  sys     0m5.114s
Previous: Elijah NewrenNext: Elijah Newren
Message 4 of 22 in “Unreliable 'git rebase --onto'”
  1. Eugeniu RoscaJan 8, 2020
  2. SZEDER GáborJan 8, 2020
  3. Elijah NewrenJan 9, 2020
  4. SZEDER GáborJan 9, 2020
  5. Elijah NewrenJan 9, 2020
  6. rebase -i: stop checking out the tip of the branch to rebaseAlban Gruin, Jan 21, 2020
  7. Elijah NewrenJan 21, 2020
  8. Junio C HamanoJan 22, 2020
  9. Junio C HamanoJan 22, 2020
  10. Alban GruinJan 24, 2020
  11. rebase -i: stop checking out the tip of the branch to rebaseAlban Gruin, Jan 24, 2020
  12. Alban GruinJan 24, 2020
  13. Junio C HamanoJan 24, 2020
  14. rebase -i: stop checking out the tip of the branch to rebaseAlban Gruin, Jan 24, 2020
  15. Junio C HamanoJan 24, 2020
  16. Johannes SchindelinFeb 5, 2020
  17. Andrei RybakJan 24, 2020
  18. Eugeniu RoscaJan 9, 2020
  19. Eugeniu RoscaJan 9, 2020
  20. Elijah NewrenJan 9, 2020
  21. Eugeniu RoscaJan 10, 2020
  22. Elijah NewrenJan 10, 2020

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.