[PATCH evolve-ext] inhibit: improve transaction marker perf

Martin von Zweigbergk martinvonz at google.com
Sat Nov 7 23:52:52 CST 2015


On Sat, Nov 7, 2015 at 5:21 PM Durham Goode <durham at fb.com> wrote:

> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1446945001 28800
> #      Sat Nov 07 17:10:01 2015 -0800
> # Node ID 7c680f209f7af35c7c476eecc2f9eec13b32ad62
> # Parent  48547b4c77defdd17c670b1eb0eb94272edf0207
> inhibit: improve transaction marker perf
>
> The old algorithm was a revset "::X and obsolete()". This was inefficient
> because
> it requires walking all the way down the ancestor chain (since the revset
> did
> not know it could stop walking at public nodes).
>

I was hoping to reproduce the slowness on the Mozilla repo (270k
revisions), but "hg log -r '::tip and obsolete()'" runs in 180 ms. Do you
have a better command for me to try? How many obsmarkers in the repo you
tried it on?


> The new algorithm uses changelog.ancestors() directly and provides a
> function to
> stop the iteration when we reach a public node. During a commit to a repo
> with
> hundreds of thousands of commits, this change reduces the inhibitmarkers
> time
> from 1.5 seconds to effectively 0 seconds.
>
> diff --git a/hgext/inhibit.py b/hgext/inhibit.py
> --- a/hgext/inhibit.py
> +++ b/hgext/inhibit.py
> @@ -23,6 +23,7 @@ from mercurial import scmutil
>  from mercurial import commands
>  from mercurial import lock as lockmod
>  from mercurial import bookmarks
> +from mercurial import phases
>  from mercurial import util
>  from mercurial.i18n import _
>
> @@ -129,7 +130,15 @@ def _inhibitmarkers(repo, nodes):
>      if not _inhibitenabled(repo):
>          return
>
> -    newinhibit = repo.set('::%ln and obsolete()', nodes)
> +    newinhibit = set()
> +    revs = [repo[node].rev() for node in nodes]
> +    phase = repo._phasecache.phase
> +    obsoletes = obsolete.getrevs(repo, 'obsolete')
> +    for anc in repo.changelog.ancestors(revs, inclusive=True,
> +                stopfunc=lambda rev: phase(repo, rev) == phases.public):
> +        if anc in obsoletes:
> +            newinhibit.add(repo[anc])
> +
>      if newinhibit:
>          lock = tr = None
>          try:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151108/37ef2271/attachment.html>


More information about the Mercurial-devel mailing list