Patchwork revset-node: speedup by a few hundred fold

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 17, 2014, 2:01 a.m.
Message ID <054db6453bb4259d5df4.1413511265@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6358/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 17, 2014, 2:01 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413016760 25200
#      Sat Oct 11 01:39:20 2014 -0700
# Node ID 054db6453bb4259d5df4aca4aa5456a888d2da42
# Parent  eaceb9c9e15a4fa0fa3efb53234782c56e4af9a6
revset-node: speedup by a few hundred fold

Instead of checking all elements of the subset against a single rev, just check
if this rev is in the subset. The old way was inherited from when the subset was
a list.

Non surprise, this provide massive speedup.


id("d82e2223f132")
before) wall 0.008205 comb 0.000000 user 0.000000 sys 0.000000 (best of 302)
after)  wall 0.000069 comb 0.000000 user 0.000000 sys 0.000000 (best of 34518)

revset #1: public() and id("d82e2223f132")
before) wall 0.019763 comb 0.020000 user 0.020000 sys 0.000000 (best of 124)
after)  wall 0.000101 comb 0.000000 user 0.000000 sys 0.000000 (best of 20130)
Augie Fackler - Oct. 17, 2014, 1:55 p.m.
On Thu, Oct 16, 2014 at 07:01:05PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1413016760 25200
> #      Sat Oct 11 01:39:20 2014 -0700
> # Node ID 054db6453bb4259d5df4aca4aa5456a888d2da42
> # Parent  eaceb9c9e15a4fa0fa3efb53234782c56e4af9a6
> revset-node: speedup by a few hundred fold

Nice. Queued.

>
> Instead of checking all elements of the subset against a single rev, just check
> if this rev is in the subset. The old way was inherited from when the subset was
> a list.
>
> Non surprise, this provide massive speedup.
>
>
> id("d82e2223f132")
> before) wall 0.008205 comb 0.000000 user 0.000000 sys 0.000000 (best of 302)
> after)  wall 0.000069 comb 0.000000 user 0.000000 sys 0.000000 (best of 34518)
>
> revset #1: public() and id("d82e2223f132")
> before) wall 0.019763 comb 0.020000 user 0.020000 sys 0.000000 (best of 124)
> after)  wall 0.000101 comb 0.000000 user 0.000000 sys 0.000000 (best of 20130)
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -1131,11 +1131,14 @@ def node_(repo, subset, x):
>          rn = None
>          pm = repo.changelog._partialmatch(n)
>          if pm is not None:
>              rn = repo.changelog.rev(pm)
>
> -    return subset.filter(lambda r: r == rn)
> +    if rn is None:
> +        return baseset()
> +    result = baseset([rn])
> +    return result & subset
>
>  def obsolete(repo, subset, x):
>      """``obsolete()``
>      Mutable changeset with a newer version."""
>      # i18n: "obsolete" is a keyword
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1131,11 +1131,14 @@  def node_(repo, subset, x):
         rn = None
         pm = repo.changelog._partialmatch(n)
         if pm is not None:
             rn = repo.changelog.rev(pm)
 
-    return subset.filter(lambda r: r == rn)
+    if rn is None:
+        return baseset()
+    result = baseset([rn])
+    return result & subset
 
 def obsolete(repo, subset, x):
     """``obsolete()``
     Mutable changeset with a newer version."""
     # i18n: "obsolete" is a keyword