Patchwork [4,of,4] checkheads: use a "lazyancestors" object for allfuturecommon

login
register
mail settings
Submitter Pierre-Yves David
Date June 10, 2017, 1:32 a.m.
Message ID <51e07bde42f5205650d0.1497058341@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21312/
State Accepted
Headers show

Comments

Pierre-Yves David - June 10, 2017, 1:32 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1496666655 -3600
#      Mon Jun 05 13:44:15 2017 +0100
# Node ID 51e07bde42f5205650d0c372b361bda78726e9db
# Parent  4f1a47b8fdacbb3f757ac7f92d783770dcf8215d
# EXP-Topic skipctx
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 51e07bde42f5
checkheads: use a "lazyancestors" object for allfuturecommon

Instead of walking all ancestors to compute the full set we now check membership
lazily. This massively speed.

On a million-ish revision repository, this remove 14 seconds from the push logic,
making the checkheads function disappear from profile.
Yuya Nishihara - June 12, 2017, 2:30 p.m.
On Sat, 10 Jun 2017 02:32:21 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1496666655 -3600
> #      Mon Jun 05 13:44:15 2017 +0100
> # Node ID 51e07bde42f5205650d0c372b361bda78726e9db
> # Parent  4f1a47b8fdacbb3f757ac7f92d783770dcf8215d
> # EXP-Topic skipctx
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 51e07bde42f5
> checkheads: use a "lazyancestors" object for allfuturecommon
> 
> Instead of walking all ancestors to compute the full set we now check membership
> lazily. This massively speed.
> 
> On a million-ish revision repository, this remove 14 seconds from the push logic,
> making the checkheads function disappear from profile.

Nice. Queued these, thanks.

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -248,11 +248,10 @@  def _headssummary(pushop):
 
     # If there are no obsstore, no post processing are needed.
     if repo.obsstore:
-        allmissing = set(outgoing.missing)
-        cctx = repo.set('%ld', outgoing.common)
-        allfuturecommon = set(c.rev() for c in cctx)
         torev = repo.changelog.rev
-        allfuturecommon.update(torev(m) for m in allmissing)
+        futureheads = set(torev(h) for h in outgoing.missingheads)
+        futureheads |= set(torev(h) for h in outgoing.commonheads)
+        allfuturecommon = repo.changelog.ancestors(futureheads, inclusive=True)
         for branch, heads in sorted(headssum.iteritems()):
             remoteheads, newheads, unsyncedheads, placeholder = heads
             result = _postprocessobsolete(pushop, allfuturecommon, newheads)