git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Git Mailing List" <git@vger.kernel.org>
Cc: Thomas Rast <tr@thomasrast.ch>,
	Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: merge-base --is-ancestor A B is unreasonably slow with unrelated history B
Date: Tue, 9 Jan 2018 14:30:59 -0500	[thread overview]
Message-ID: <2aa20617-6b1d-f5a4-d6e1-250a3ea8f5be@gmail.com> (raw)
In-Reply-To: <87608bawoa.fsf@evledraar.gmail.com>

On 1/9/2018 10:17 AM, Ævar Arnfjörð Bjarmason wrote:
> This is a pathological case I don't have time to dig into right now:
>
>      git branch -D orphan;
>      git checkout --orphan orphan &&
>      git reset --hard &&
>      touch foo &&
>      git add foo &&
>      git commit -m"foo" &&
>      time git merge-base --is-ancestor master orphan
>
> This takes around 5 seconds on linux.git to return 1. Which is around
> the same time it takes to run current master against the first commit in
> linux.git:
>
>      git merge-base --is-ancestor 1da177e4c3f4 master
>
> This is obviously a pathological case, but maybe we should work slightly
> harder on the RHS of and discover that it itself is an orphan commit.
>
> I ran into this while writing a hook where we'd like to do:
>
>      git diff $master...topic
>
> Or not, depending on if the topic is an orphan or just something
> recently branched off, figured I could use --is-ancestor as on
> optimization, and then discovered it's not much of an optimization.

Ævar,

This is the same performance problem that we are trying to work around 
with Jeff's "Add --no-ahead-behind to status" patch [1]. For commits 
that are far apart, many commits need to be parsed. I think the right 
solution is to create a serialized commit graph that stores the 
adjacency information of the commits and can create commit structs 
quickly. This requires storing the commit id, commit date, parents, and 
root tree id to satisfy the needs of parse_commit_gently(). Once the 
framework for this data is constructed, it is simple to add generation 
numbers to that data and start consuming them in other algorithms (by 
adding the field to 'struct commit').

I'm working on such a patch right now, but it will be a few weeks before 
I'm ready.

Thanks,
-Stolee

[1] v5 of --no-ahead-behind 
https://public-inbox.org/git/20180109185018.69164-1-git@jeffhostetler.com/T/#t

[2] v4 of --no-ahead-behind 
https://public-inbox.org/git/nycvar.QRO.7.76.6.1801091744540.37@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz/T/#t



  parent reply	other threads:[~2018-01-09 19:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 15:17 Ævar Arnfjörð Bjarmason
2018-01-09 19:13 ` Junio C Hamano
2018-01-09 19:30 ` Derrick Stolee [this message]
2018-01-10 14:01   ` Ævar Arnfjörð Bjarmason

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=2aa20617-6b1d-f5a4-d6e1-250a3ea8f5be@gmail.com \
    --to=stolee@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=tr@thomasrast.ch \
    --subject='Re: merge-base --is-ancestor A B is unreasonably slow with unrelated history B' \
    /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

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git