git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Elijah Newren" <newren@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>, entwicklung@pengutronix.de
Subject: Re: time needed to rebase shortend by using --onto?
Date: Sat, 29 May 2021 11:59:43 -0500	[thread overview]
Message-ID: <60b272ff6bfa4_265861208d6@natae.notmuch> (raw)
In-Reply-To: <20210528214024.vw4huojcklrm6d27@pengutronix.de>

Uwe Kleine-König wrote:
> I do the rebase now once before the timing for the reasons described in
> the comment. The second identical command is quite a bit quicker. Also
> now that the commands are scripted they are done in a smaller time frame
> (which matters as the machine is used heavily among my colleagues and
> me). I run the script a few times in a row, after all colleagues are in
> their week-end:
> 
> 	ukl@dude.ptx:~/gsrc/linux$ bash rebasecheck 
> 	...
> 	rebase v5.10
> 	...
> 	real	1m13.579s
> 	user	1m2.919s
> 	sys	0m6.220s
> 	...
> 	rebase --onto v5.10 v5.4
> 	...
> 	real	1m2.852s
> 	user	0m53.780s
> 	sys	0m6.225s
> 
> 	ukl@dude.ptx:~/gsrc/linux$ bash rebasecheck 
> 	...
> 	rebase v5.10
> 	...
> 	real	1m10.816s
> 	user	1m3.344s
> 	sys	0m6.991s
> 	...
> 	rebase --onto v5.10 v5.4
> 	...
> 	real	0m59.695s
> 	user	0m53.510s
> 	sys	0m5.579s
> 
> 	ukl@dude.ptx:~/gsrc/linux$ bash rebasecheck 
> 	...
> 	rebase v5.10
> 	...
> 	real	1m9.688s
> 	user	1m3.346s
> 	sys	0m6.105s
> 	...
> 	rebase --onto v5.10 v5.4
> 	...
> 	real	0m59.981s
> 	user	0m52.931s
> 	sys	0m6.282s
> 
> So it's not a factor 2 any more, but still reproducibly quicker when
> --onto is used.

Years ago I completely rewrote `git rebase` to use `git cherry-pick`,
and the result is a very simple command:

  git checkout $onto
  git cherry-pick --no-merges --right-only --topo-order --do-walk
    @{upstream}..v5.4

The difference when you don't specify --onto is basically that both onto
and upstream are considered the same:

  git checkout $onto
  git cherry-pick --no-merges --right-only --topo-order --do-walk
    $onto..v5.4

Therefore it should be more efficient to specify --onto.

Except git tries to be smart and first tries to check if a fast-forward
is possible, even if you specify --no-ff (a mistake IMO).

To check for linear history the old code used to do:

  git rev-list --parents $onto..v5.4 | grep " .* "

Maybe that is too slow in your particular situation.

You could try --restrict-revisions=v5.10 (or anything other than the
merge base), but apparently that only works with --interactive.

Another option is just hack git to disable the linear history check:

diff --git a/builtin/rebase.c b/builtin/rebase.c
index 12f093121d..bdbcfaa58e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1145,6 +1145,10 @@ static int can_fast_forward(struct commit *onto, struct commit *upstream,
        }
 
        oidcpy(merge_base, &merge_bases->item->object.oid);
+
+       /* Hack to avoid linear history check */
+       goto done;
+
        if (!oideq(merge_base, &onto->object.oid))
                goto done;
 

Cheers.

-- 
Felipe Contreras

  parent reply	other threads:[~2021-05-29 16:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 10:09 time needed to rebase shortend by using --onto? Uwe Kleine-König
2021-05-26 11:04 ` Bagas Sanjaya
2021-05-26 14:38 ` Elijah Newren
2021-05-27 21:59   ` Uwe Kleine-König
2021-05-27 22:15     ` Uwe Kleine-König
2021-05-28  5:38       ` Elijah Newren
2021-05-27 23:08     ` Elijah Newren
2021-05-28 21:40       ` Uwe Kleine-König
2021-05-28 22:26         ` Elijah Newren
2021-05-29 16:59         ` Felipe Contreras [this message]
2021-05-26 22:18 ` Junio C Hamano
2021-05-27 22:16   ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60b272ff6bfa4_265861208d6@natae.notmuch \
    --to=felipe.contreras@gmail.com \
    --cc=entwicklung@pengutronix.de \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).