spanset: directly use __contains__ instead of a lambda stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Sat, 26 Apr 2014 00:38:02 -0700
branchstable
changeset 21207 b9defeeb62e6
parent 21206 c77418938d05
child 21208 0e1cbd3d52f7
spanset: directly use __contains__ instead of a lambda Spanset are massively used in revset. First because the initial subset itself is a repo wide spanset. We speed up the __and__ operation by getting rid of a gratuitous lambda call. A more long terms solution would be to: 1. speed up operation between spansets, 2. have a special smartset for `all` revisions. In the mean time, this is a very simple fix that buyback some of the performance regression. Below is performance benchmark for trival `and` operation between two spansets. (Run on an unspecified fairly large repository.) revset tip:0 2.9.2) wall 0.282543 comb 0.280000 user 0.260000 sys 0.020000 (best of 35) before) wall 0.819181 comb 0.820000 user 0.820000 sys 0.000000 (best of 12) after) wall 0.645358 comb 0.650000 user 0.650000 sys 0.000000 (best of 16) Proof of concept implementation of an `all` smartset brings this to 0.10 but it's too invasive for stable.
mercurial/revset.py
--- a/mercurial/revset.py	Wed Apr 30 15:36:38 2014 -0700
+++ b/mercurial/revset.py	Sat Apr 26 00:38:02 2014 -0700
@@ -2797,9 +2797,9 @@
         if isinstance(x, baseset):
             x = x.set()
         if self._start <= self._end:
-            return orderedlazyset(self, lambda r: r in x)
+            return orderedlazyset(self, x.__contains__)
         else:
-            return orderedlazyset(self, lambda r: r in x, ascending=False)
+            return orderedlazyset(self, x.__contains__, ascending=False)
 
     def __sub__(self, x):
         if isinstance(x, baseset):