git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Andreas Krey <a.krey@gmx.de>
Cc: git@vger.kernel.org, Derrick Stolee <stolee@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: Speed of git branch --contains
Date: Wed, 24 Jan 2018 17:20:13 +0100	[thread overview]
Message-ID: <87607rgreq.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20180123203656.GA27016@inner.h.apk.li>


On Tue, Jan 23 2018, Andreas Krey jotted:

> I'm just looking at some scripts that do a 'git branch --contains $id --remote'
> for each new commit in a repo, and unfortunately each invokation already
> takes four minutes.
>
> It feels like git branch does the reachability detection separately
> for each branch potentially listed. The alternative would be to
>
> - invert the parent map to a child map,
> - use that to compute the set of commits that contain $id,
> - then use that as predicate whether to show a given branch
>   (show iff its head is in the set)
>
> That would speed things up considerably,
> but what are the chances to see that change in git?
>
> I can do that as well within the script, with the additional
> benefit that I only need to do the inversion once, but I might
> instead take a stab at git branch.

I posted something similar to the list the other day, and Derrick had a
great follow-up to that which summarized the current work on this:
https://public-inbox.org/git/87608bawoa.fsf@evledraar.gmail.com/

Junio mentioned an edge case in that thread which you may not have
thought of (I didn't). I.e. that one problem with such a mapping is that
a new branch may at any point push new history which includes your
commit as a merge, forcing you to re-compute this child map.

That can be optimized by checking whether some commits come after others
timestamp wise, but that brings us to the problem that timestamps aren't
guaranteed to be monotonically increasing (and may even be years off) by
git, which is another optimization challenge for things like --contains.

      reply	other threads:[~2018-01-24 16:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23 20:36 Speed of git branch --contains Andreas Krey
2018-01-24 16:20 ` Ævar Arnfjörð Bjarmason [this message]

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=87607rgreq.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=a.krey@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stolee@gmail.com \
    /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).