git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* commit-graph is cool (overcoming add_missing_tags() perf issues)
@ 2018-10-17 18:00 Elijah Newren
  2018-10-17 18:19 ` Derrick Stolee
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Elijah Newren @ 2018-10-17 18:00 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: Git Mailing List

Hi,

Just wanted to give a shout-out for the commit-graph work and how
impressive it is.  I had an internal report from a user that git
pushes containing only one new tiny commit were taking over a minute
(in a moderate size repo with good network connectivity). After
digging for a while, I noticed three unusual things about the repo[1]:
  * he had push.followTags set to true
  * upstream repo had about 20k tags (despite only 55k commits)
  * his repo had an additional 2.5k tags, but none of these were in
    the history of the branches he was pushing and thus would not be
    included in any pushes.

Digging in, almost all the time was CPU-bound and spent in
add_missing_tags()[2].  If I'm reading the code correctly, it appears
that function loops over each tag, calling in_merge_bases_many() once
per tag.  Thus, for his case, we were potentially walking all of
history of the main branch 2.5k times.  That seemed rather suboptimal.

Before attempting to optimize, I decided to try out the commit-graph
with a version of git from pu.  While I expected a speed-up, I was a
bit suprised that it was a factor of over 100; dropping the time for
local dry-run push[2] to sub-second.  A quick look suggests that
commit-graph doesn't fix the fact that we call in_merge_bases_many() N
times from add_missing_tags() and thus likely need to do N merge base
computations, it just makes each of the N much faster.  So, perhaps
there's still another scaling issue we'll eventually need to address,
but for now, I'm pretty excited about commit-graph.

(And in the mean time I gave the user a one-liner to nuke his
local-only tags that I suspect he doesn't need.)

Thanks,
Elijah


[1] lerna seems to scale horribly, especially when you suddenly
transition dozens of web developers and even more independent
repositories into a single large monorepo.  Usage of lerna was
thankfully ripped out at some point, but the crazy number of
historical tags remain.  Also, this user did a bunch of the
filter-branch'ing to suck extra repos into the monorepo, likely
involved somehow in the many extra tags he had.

[2] In fact, I still had timings of over a minute when adjusting the command to:
  git push --follow-tags --dry-run /PATH/TO/LOCAL-MIRROR $BRANCH

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: commit-graph is cool (overcoming add_missing_tags() perf issues)
  2018-10-17 18:00 commit-graph is cool (overcoming add_missing_tags() perf issues) Elijah Newren
@ 2018-10-17 18:19 ` Derrick Stolee
  2018-10-17 18:31 ` Jeff King
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Derrick Stolee @ 2018-10-17 18:19 UTC (permalink / raw)
  To: Elijah Newren, Derrick Stolee; +Cc: Git Mailing List

On 10/17/2018 2:00 PM, Elijah Newren wrote:
> Hi,
>
> Just wanted to give a shout-out for the commit-graph work and how
> impressive it is.  I had an internal report from a user that git
> pushes containing only one new tiny commit were taking over a minute
> (in a moderate size repo with good network connectivity). After
> digging for a while, I noticed three unusual things about the repo[1]:
>    * he had push.followTags set to true
>    * upstream repo had about 20k tags (despite only 55k commits)
>    * his repo had an additional 2.5k tags, but none of these were in
>      the history of the branches he was pushing and thus would not be
>      included in any pushes.
>
> Digging in, almost all the time was CPU-bound and spent in
> add_missing_tags()[2].  If I'm reading the code correctly, it appears
> that function loops over each tag, calling in_merge_bases_many() once
> per tag.  Thus, for his case, we were potentially walking all of
> history of the main branch 2.5k times.  That seemed rather suboptimal.

Thanks for the report. I made a note to inspect add_missing_tags() for 
more improvement in the future.

> Before attempting to optimize, I decided to try out the commit-graph
> with a version of git from pu.  While I expected a speed-up, I was a
> bit suprised that it was a factor of over 100; dropping the time for
> local dry-run push[2] to sub-second.  A quick look suggests that
> commit-graph doesn't fix the fact that we call in_merge_bases_many() N
> times from add_missing_tags() and thus likely need to do N merge base
> computations, it just makes each of the N much faster.  So, perhaps
> there's still another scaling issue we'll eventually need to address,
> but for now, I'm pretty excited about commit-graph.

Without the commit-graph, you are getting a quadratic problem (N commits 
* T tags), but with the commit-graph you are also getting the benefit of 
generation numbers, so the "N commits" is actually likely _zero_ for 
most tags, because the tags have strictly lower generation number. In 
those cases, we can terminate without any walk at all.

Thanks!
-Stolee


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: commit-graph is cool (overcoming add_missing_tags() perf issues)
  2018-10-17 18:00 commit-graph is cool (overcoming add_missing_tags() perf issues) Elijah Newren
  2018-10-17 18:19 ` Derrick Stolee
@ 2018-10-17 18:31 ` Jeff King
  2018-10-30 14:22 ` Derrick Stolee
  2018-10-30 16:22 ` Ævar Arnfjörð Bjarmason
  3 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2018-10-17 18:31 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Derrick Stolee, Git Mailing List

On Wed, Oct 17, 2018 at 11:00:03AM -0700, Elijah Newren wrote:

> Digging in, almost all the time was CPU-bound and spent in
> add_missing_tags()[2].  If I'm reading the code correctly, it appears
> that function loops over each tag, calling in_merge_bases_many() once
> per tag.  Thus, for his case, we were potentially walking all of
> history of the main branch 2.5k times.  That seemed rather suboptimal.
> 
> Before attempting to optimize, I decided to try out the commit-graph
> with a version of git from pu.  While I expected a speed-up, I was a
> bit suprised that it was a factor of over 100; dropping the time for
> local dry-run push[2] to sub-second.  A quick look suggests that
> commit-graph doesn't fix the fact that we call in_merge_bases_many() N
> times from add_missing_tags() and thus likely need to do N merge base
> computations, it just makes each of the N much faster.  So, perhaps
> there's still another scaling issue we'll eventually need to address,
> but for now, I'm pretty excited about commit-graph.

Yeah, I think this case would probably still benefit from an all-points
traversal. This want to be basically the same as what "git tag --merged"
is doing, I would think (see ref-filter.c:do_merge_filter).

  As an aside, it looks like do_merge_filter uses prepare_revision_walk(),
  which IIRC means that it is susceptible to wrong answers due to
  clock skew (basically because of the use of commit timestamps for
  traversal order). This seems like another place where generation
  numbers could make a quiet improvement.

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: commit-graph is cool (overcoming add_missing_tags() perf issues)
  2018-10-17 18:00 commit-graph is cool (overcoming add_missing_tags() perf issues) Elijah Newren
  2018-10-17 18:19 ` Derrick Stolee
  2018-10-17 18:31 ` Jeff King
@ 2018-10-30 14:22 ` Derrick Stolee
  2018-10-31  5:45   ` Elijah Newren
  2018-10-30 16:22 ` Ævar Arnfjörð Bjarmason
  3 siblings, 1 reply; 7+ messages in thread
From: Derrick Stolee @ 2018-10-30 14:22 UTC (permalink / raw)
  To: Elijah Newren, Derrick Stolee; +Cc: Git Mailing List

On 10/17/2018 2:00 PM, Elijah Newren wrote:
> Hi,
>
> Just wanted to give a shout-out for the commit-graph work and how
> impressive it is.  I had an internal report from a user that git
> pushes containing only one new tiny commit were taking over a minute
> (in a moderate size repo with good network connectivity). After
> digging for a while, I noticed three unusual things about the repo[1]:
>    * he had push.followTags set to true
>    * upstream repo had about 20k tags (despite only 55k commits)
>    * his repo had an additional 2.5k tags, but none of these were in
>      the history of the branches he was pushing and thus would not be
>      included in any pushes.
>
> Digging in, almost all the time was CPU-bound and spent in
> add_missing_tags()[2].  If I'm reading the code correctly, it appears
> that function loops over each tag, calling in_merge_bases_many() once
> per tag.  Thus, for his case, we were potentially walking all of
> history of the main branch 2.5k times.  That seemed rather suboptimal.

Elijah,

Do you still have this repo around? Could you by chance test the 
performance with the new algorithm for add_missing_tags() in [1]? 
Specifically, please test it without a commit-graph file, since your 
data shape already makes use of generation numbers pretty well.

Thanks,
-Stolee

[1] https://public-inbox.org/git/pull.60.git.gitgitgadget@gmail.com/T/#t

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: commit-graph is cool (overcoming add_missing_tags() perf issues)
  2018-10-17 18:00 commit-graph is cool (overcoming add_missing_tags() perf issues) Elijah Newren
                   ` (2 preceding siblings ...)
  2018-10-30 14:22 ` Derrick Stolee
@ 2018-10-30 16:22 ` Ævar Arnfjörð Bjarmason
  2018-10-31  5:46   ` Elijah Newren
  3 siblings, 1 reply; 7+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-10-30 16:22 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Derrick Stolee, Git Mailing List

On Wed, Oct 17, 2018 at 8:41 PM Elijah Newren <newren@gmail.com> wrote:
> (And in the mean time I gave the user a one-liner to nuke his
> local-only tags that I suspect he doesn't need.)

Just a note that you can usually set 'fetch.pruneTags=true' these days
to make that happen.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: commit-graph is cool (overcoming add_missing_tags() perf issues)
  2018-10-30 14:22 ` Derrick Stolee
@ 2018-10-31  5:45   ` Elijah Newren
  0 siblings, 0 replies; 7+ messages in thread
From: Elijah Newren @ 2018-10-31  5:45 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: Derrick Stolee, Git Mailing List

On Tue, Oct 30, 2018 at 7:22 AM Derrick Stolee <stolee@gmail.com> wrote:
>
> On 10/17/2018 2:00 PM, Elijah Newren wrote:
> > Hi,
> >
> > Just wanted to give a shout-out for the commit-graph work and how
> > impressive it is.  I had an internal report from a user that git
> > pushes containing only one new tiny commit were taking over a minute
> > (in a moderate size repo with good network connectivity). After
> > digging for a while, I noticed three unusual things about the repo[1]:
> >    * he had push.followTags set to true
> >    * upstream repo had about 20k tags (despite only 55k commits)
> >    * his repo had an additional 2.5k tags, but none of these were in
> >      the history of the branches he was pushing and thus would not be
> >      included in any pushes.
> >
> > Digging in, almost all the time was CPU-bound and spent in
> > add_missing_tags()[2].  If I'm reading the code correctly, it appears
> > that function loops over each tag, calling in_merge_bases_many() once
> > per tag.  Thus, for his case, we were potentially walking all of
> > history of the main branch 2.5k times.  That seemed rather suboptimal.
>
> Elijah,
>
> Do you still have this repo around? Could you by chance test the
> performance with the new algorithm for add_missing_tags() in [1]?
> Specifically, please test it without a commit-graph file, since your
> data shape already makes use of generation numbers pretty well.
>
> Thanks,
> -Stolee

I nuked it, but turns out I had a backup that I found after digging
around for a bit.  I'll post a comment on the series with the results.

By the way, I've been running pu for about a week with this tweak:

diff --git a/revision.c b/revision.c
index b5108b75ab..d20c687e71 100644
--- a/revision.c
+++ b/revision.c
@@ -1457,6 +1457,7 @@ void repo_init_revisions(struct repository *r,
        revs->pruning.change = file_change;
        revs->pruning.change_fn_data = revs;
        revs->sort_order = REV_SORT_IN_GRAPH_ORDER;
+       revs->topo_order = 1;
        revs->dense = 1;
        revs->prefix = prefix;
        revs->max_age = -1;

Only ran into one small problem once, and it wasn't commit-graph
related; rather it was related to my above patch and needing to not
have topo_order be set.  (I just bailed and used my older
system-installed git from /usr/bin/ in that one case.)  So, I think
the commit-graph stuff is looking pretty good, and I find the recent
thread on further improvements with corrected commit date (among other
possibilities) very intriguing...even if I haven't had much time to
comment or test recently.

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: commit-graph is cool (overcoming add_missing_tags() perf issues)
  2018-10-30 16:22 ` Ævar Arnfjörð Bjarmason
@ 2018-10-31  5:46   ` Elijah Newren
  0 siblings, 0 replies; 7+ messages in thread
From: Elijah Newren @ 2018-10-31  5:46 UTC (permalink / raw)
  To: Ævar Arnfjörð; +Cc: Derrick Stolee, Git Mailing List

On Tue, Oct 30, 2018 at 9:23 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> On Wed, Oct 17, 2018 at 8:41 PM Elijah Newren <newren@gmail.com> wrote:
> > (And in the mean time I gave the user a one-liner to nuke his
> > local-only tags that I suspect he doesn't need.)
>
> Just a note that you can usually set 'fetch.pruneTags=true' these days
> to make that happen.

TIL.  Thanks for the heads up.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-31  5:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-17 18:00 commit-graph is cool (overcoming add_missing_tags() perf issues) Elijah Newren
2018-10-17 18:19 ` Derrick Stolee
2018-10-17 18:31 ` Jeff King
2018-10-30 14:22 ` Derrick Stolee
2018-10-31  5:45   ` Elijah Newren
2018-10-30 16:22 ` Ævar Arnfjörð Bjarmason
2018-10-31  5:46   ` Elijah Newren

Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).