Commit Graph

8 Commits

Author SHA1 Message Date
Gregory Szorc
5ca0f908bf py3: add __bool__ to every class defining __nonzero__
__nonzero__ was renamed to __bool__ in Python 3. This patch simply
aliases __bool__ to __nonzero__ for every class implementing
__nonzero__.
2017-03-13 12:40:14 -07:00
Yuya Nishihara
ec012a1a69 py3: use next() to obtain next item from inner generator of generatorset
.next attribute does not exist on Python 3. As this function seems to really
care about the overhead of the Python interpreter, I follow the way of micro
optimization.
2017-03-13 08:53:31 -07:00
Yuya Nishihara
51c8b96882 smartset: reorder initialization of baseset in more intuitive way
What we want to do is to assign either _set or _list per the given data
type.
2017-02-18 17:37:52 +09:00
Jun Wu
11f41ac7b5 smartset: preserve istopo for baseset operations
This is a follow-up of "smartset: use native set operations as fast paths".
It's more correct to just preserve the "istopo" information for "&" and "-"
operations, like what filteredset does.
2017-02-21 16:29:31 -08:00
Jun Wu
8b91946180 smartset: use native set operations as fast paths
For set operations like "&" and "-", where we know both basesets have their
sets ready, and the first set is sorted, use the native Python set
operations as a fast path.

Note: "+" is not optimized as that will break the ordering.

This leads to noticeable improvements on performance:

  revset                                | before | after | delta
  ----------------------------------------------------------------
  draft() & draft() & draft() & draft() |    776 |   477 | -39%
  draft() + draft() + draft() + draft() |   2849 |  2864 |
  draft() - draft() + draft() - draft() |    943 |   240 | -75%
  draft() - draft() - draft() - draft() |    557 |   197 | -64%

  (time measured in microseconds)
2017-02-18 17:23:43 -08:00
Jun Wu
5b7a815bb7 smartset: add some doctests
Add doctests explaining the set / list behavior. This will make the
following changes more confident.
2017-02-18 16:30:07 -08:00
Jun Wu
e5340d9f4b smartset: convert set to list lazily
If the caller only wants to construct a baseset via a set, and then do
"__contains__" tests. It's unnecessary to initialize the list.

Testing on my unfiltered hg-committed repo where len(draft()) is 2600, this
patch shows about 6% improvement on set intensive queries:

Before:

  $ for i in `seq 5`; hg perfrevset 'draft() & draft() & draft() & draft()'
  ! wall 0.001196 comb 0.000000 user 0.000000 sys 0.000000 (best of 2011)
  ! wall 0.001191 comb 0.000000 user 0.000000 sys 0.000000 (best of 2099)
  ! wall 0.001186 comb 0.010000 user 0.010000 sys 0.000000 (best of 1953)
  ! wall 0.001182 comb 0.000000 user 0.000000 sys 0.000000 (best of 2135)
  ! wall 0.001193 comb 0.000000 user 0.000000 sys 0.000000 (best of 2177)

After:

  $ for i in `seq 5`; hg perfrevset 'draft() & draft() & draft() & draft()'
  ! wall 0.001128 comb 0.000000 user 0.000000 sys 0.000000 (best of 2247)
  ! wall 0.001119 comb 0.000000 user 0.000000 sys 0.000000 (best of 2317)
  ! wall 0.001115 comb 0.000000 user 0.000000 sys 0.000000 (best of 2244)
  ! wall 0.001131 comb 0.000000 user 0.000000 sys 0.000000 (best of 2093)
  ! wall 0.001124 comb 0.000000 user 0.000000 sys 0.000000 (best of 2134)

It could have bigger impact on larger sets in theory.
2017-02-17 20:59:29 -08:00
Yuya Nishihara
2e50d5587f smartset: move set classes and related functions from revset module (API)
These classes are pretty large and independent from revset computation.

  2961 mercurial/revset.py
   973 mercurial/smartset.py
  3934 total

revset.prettyformatset() is renamed to smartset.prettyformat(). Smartset
classes are aliased since they are quite common in revset.py.
2016-10-16 17:28:51 +09:00