[PATCH 3 of 3 STABLE] remotephase: avoid full changelog iteration (issue5964)

Yuya Nishihara yuya at tcha.org
Sat Aug 18 01:43:41 EDT 2018


On Fri, 17 Aug 2018 23:42:16 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld at octobus.net>
> # Date 1534530952 -7200
> #      Fri Aug 17 20:35:52 2018 +0200
> # Branch stable
> # Node ID 1c92e2f2b7f64d7e975846de6fae36a1415ffe84
> # Parent  0fee760d9736505d2315b8452ae9a60053ebefa0
> # EXP-Topic phases-perf
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1c92e2f2b7f6
> remotephase: avoid full changelog iteration (issue5964)
> 
> Changeset 88efb7d6bcb6 introduced a performance regression by triggering a
> full ancestors walk.
> 
> This changeset reworks this logic so that we no longer walk down the full
> changelog. The motivation for 88efb7d6bcb6, issue5939, is still fixed.
> 
> mercurial compared to a draft repository
> ----------------------------------------
> 
> 8eeed92475d5: 0.012637 seconds
> 88efb7d6bcb6: 0.202699 seconds (x16)
> 46da52f4b820: 0.215551 seconds (+6%)
> this code:    0.008397 seconds (-33% from base)
> 
> The payload size reduction we see in `test-bookmarks-pushpull.t` comes from a
> more aggressive filter of nullid and is harmless.
> 
> diff --git a/mercurial/phases.py b/mercurial/phases.py
> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -664,11 +664,39 @@ def newheads(repo, heads, roots):
>  
>      * `heads`: define the first subset
>      * `roots`: define the second we subtract from the first"""
> +    # prevent an import cycle
> +    # phases > dagop > patch > copies > scmutil > obsolete > obsutil > phases
> +    from . import dagop
> +
> +    repo = repo.unfiltered()
> +    cl = repo.changelog
> +    rev = cl.nodemap.get
> +    if not roots:
> +        return heads
> +    if not heads or heads == [nullrev]:
                                ^^^^^^^^^
                                [nullid] ?

> +        return []
> +    # The logic operated on revisions, convert arguments early for convenience
> +    new_heads = set(rev(n) for n in heads if n != nullid)
> +    roots = [rev(n) for n in roots]

>      if not heads or not roots:
>          return heads

Nit: maybe dead code?


More information about the Mercurial-devel mailing list