Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 21207:b9defeeb62e6 stable
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 26 Apr 2014 00:38:02 -0700 |
parents | e2031c8ca4f8 |
children | 0952904dc1e5 |
comparison
equal
deleted
inserted
replaced
21206:c77418938d05 | 21207:b9defeeb62e6 |
---|---|
2795 | 2795 |
2796 def __and__(self, x): | 2796 def __and__(self, x): |
2797 if isinstance(x, baseset): | 2797 if isinstance(x, baseset): |
2798 x = x.set() | 2798 x = x.set() |
2799 if self._start <= self._end: | 2799 if self._start <= self._end: |
2800 return orderedlazyset(self, lambda r: r in x) | 2800 return orderedlazyset(self, x.__contains__) |
2801 else: | 2801 else: |
2802 return orderedlazyset(self, lambda r: r in x, ascending=False) | 2802 return orderedlazyset(self, x.__contains__, ascending=False) |
2803 | 2803 |
2804 def __sub__(self, x): | 2804 def __sub__(self, x): |
2805 if isinstance(x, baseset): | 2805 if isinstance(x, baseset): |
2806 x = x.set() | 2806 x = x.set() |
2807 if self._start <= self._end: | 2807 if self._start <= self._end: |