Patchwork revset: make descendants() lazier

login
register
mail settings
Submitter Durham Goode
Date Sept. 12, 2014, 11:51 p.m.
Message ID <ccf0d9add601e7185b09.1410565882@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/5815/
State Accepted
Headers show

Comments

Durham Goode - Sept. 12, 2014, 11:51 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1410564073 25200
#      Fri Sep 12 16:21:13 2014 -0700
# Node ID ccf0d9add601e7185b09326a91f4575ffb116858
# Parent  492b3be70dcb22d39d7404a4154bed1dd8c25ffa
revset: make descendants() lazier

Previously descendants() would force the provided subset to become a set.  In
the case of revsets like '(%ld::) - (%ld)' (as used by histedit) this would
force the '- (%ld)' set to be evaluated, which produced a set containing every
commit in the repo (except %ld). This takes 0.6s on large repos.

This changes descendants to trust the subset to implement __contains__
efficiently, which improves the above revset to 0.16s. Shaving 0.4 seconds off
of histedit.

revset #27: (20000::) - (20000)
0) obsolete feature not enabled but 54243 markers found!
! wall 0.023640 comb 0.020000 user 0.020000 sys 0.000000 (best of 100)
1) obsolete feature not enabled but 54243 markers found!
! wall 0.019589 comb 0.020000 user 0.020000 sys 0.000000 (best of 100)

This commit removes the final revset related perf hotspot from histedit.
Combined with the previous two patches, they shave a little over 3 seconds off
histedit on large repos.
Matt Mackall - Sept. 16, 2014, 4:44 p.m.
On Fri, 2014-09-12 at 16:51 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1410564073 25200
> #      Fri Sep 12 16:21:13 2014 -0700
> # Node ID ccf0d9add601e7185b09326a91f4575ffb116858
> # Parent  492b3be70dcb22d39d7404a4154bed1dd8c25ffa
> revset: make descendants() lazier

Queued for default, thanks.

Patch

diff --git a/contrib/revsetbenchmarks.txt b/contrib/revsetbenchmarks.txt
--- a/contrib/revsetbenchmarks.txt
+++ b/contrib/revsetbenchmarks.txt
@@ -25,3 +25,4 @@ 
 (not public() - obsolete())
 (_intlist('20000\x0020001')) and merge()
 parents(20000)
+(20000::) - (20000)
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -666,10 +666,8 @@ 
     # Both sets need to be ascending in order to lazily return the union
     # in the correct order.
     args.ascending()
-
-    subsetset = subset.set()
-    result = (orderedlazyset(s, subsetset.__contains__, ascending=True) +
-              orderedlazyset(args, subsetset.__contains__, ascending=True))
+    result = (orderedlazyset(s, subset.__contains__, ascending=True) +
+              orderedlazyset(args, subset.__contains__, ascending=True))
 
     # Wrap result in a lazyset since it's an _addset, which doesn't implement
     # all the necessary functions to be consumed by callers.