Commit Graph

343 Commits

Author SHA1 Message Date
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Mads Kiilerich
b117005b7c revlog: use context ancestor instead of changelog ancestor
We want to move in this direction.
2014-04-07 23:17:51 +02:00
Durham Goode
eac8ba4613 revset: improve roots revset performance
Previously we would iterate over every item in the subset, checking if it was in
the provided args. This often meant iterating over every rev in the repo.

Now we iterate over the args provided, checking if they exist in the subset.
On a large repo this brings setting phase boundaries (which use this revset
roots(X:: - X::Y)) down from 0.8 seconds to 0.4 seconds.

The "roots((tip~100::) - (tip~100::tip))" revset in revsetbenchmarks shows it
going from 0.12s to 0.10s, so we should be able to catch regressions here in the
future.

This actually introduces a regression in 'roots(all())' (0.2s to 0.26s) since
we're now using spansets, which are slightly slower to do containment checks on.
I believe this trade off is worth it, since it makes the revset O(number of
args) instead of O(size of repo).
2014-03-31 16:03:34 -07:00
Durham Goode
13db32b575 revset: improve _descendants performance
Previously revset._descendants would iterate over the entire subset (which is
often the entire repo) and test if each rev was in the descendants list. This is
really slow on large repos (3+ seconds).

Now we iterate over the descendants and test if they're in the subset.
This affects advancing and retracting the phase boundary (3.5 seconds down to
0.8 seconds, which is even faster than it was in 2.9). Also affects commands
that move the phase boundary (commit and rebase, presumably).

The new revsetbenchmark indicates an improvement from 0.2 to 0.12 seconds. So
future revset changes should be able to notice regressions.

I removed a bad test. It was recently added and tested '1:: and reverse(all())',
which has an amibiguous output direction.  Previously it printed in reverse order,
because we iterated over the subset (the reverse part). Now it prints in normal
order because we iterate over the 1:: . Since the revset itself doesn't imply an
order, I removed the test.
2014-03-25 14:10:01 -07:00
Pierre-Yves David
3a1c934d6a revset: raise ValueError when calling min or max on empty smartset
min([]) raise a ValueError, we do the same thing in smartset.min() and
smartset.max() for the sake of consistency.

The min/amax test are greatly improved in the process to prevent this familly
of regression
2014-03-28 17:00:13 -07:00
Pierre-Yves David
4e0cea0c36 _addset: add a __len__ method
Back in the time where repo.revs(...) returned a list, calling `len(...)` on the
result was quite common. We reinstall this on _addset.

There is absolutely no easy way to test this from the command line. The commands
using this in the evolve extension will eventually land into core.
2014-03-20 18:55:28 -07:00
Durham Goode
dd74d4bd47 revset: fix generatorset race condition
If two things were iterating over a generatorset at the same time, they could
miss out on the things the other was generating, resulting in incomplete
results. This fixes it by making it possible for two things to iterate at once,
by always checking the _genlist at the beginning of each iteration.

I was only able to repro it with pending changes from my other commits, but they
aren't ready yet. So I'm unable to add a test for now.
2014-03-25 16:10:07 -07:00
Matt Mackall
b465bcd596 merge with stable 2014-03-25 16:17:16 -05:00
Gregory Szorc
2e930ae769 revset: improve performance of _generatorset.__contains__ (issue 4201)
_generatorset.__contains__ and __contains__ from child classes were
calling into __iter__ to look for values. Since all
previously-encountered values from the generator were cached and checked
in __contains__ before this iteration, __contains__ was effectively
performing iteration busy work which could lead to an explosion of
redundant work.

This patch changes __contains__ to be more intelligent. Instead of
looking at all values via __iter__, __contains__ will instead go
straight to "new" values from the underlying generator.

On a clone of the Firefox repository with around 200,000 changesets,
this patch decreases the execution time of the revset '::(200067)::'
from ~100s to ~4s on the author's machine. Rebase operations (which use
the aforementioned revset), speed up accordingly.
2014-03-24 20:00:18 -07:00
Matt Harbison
60d20455df revset: document the regular expression support for tag(name)
This has been supported since 0041ea008c64, in 2.3.
2014-03-24 21:27:40 -04:00
Matt Mackall
4436b1c4a4 revset: try to handle hyphenated symbols if lookup callback is available
Formerly an expression like "2.4-rc::" was tokenized as 2.4|-|rc|::.
This allows dashes in symbols iff the whole symbol-like string can be
looked up. Otherwise, it's tokenized as a series of symbols and
operators.

No attempt is made to accept dashed symbols inside larger symbol-like
string, for instance foo-bar or bar-baz inside foo-bar-baz.
2014-03-18 17:54:42 -05:00
Matt Mackall
a9a943eddd revset: pass a lookup function to the tokenizer 2014-03-18 17:19:44 -05:00
Lucas Moscovicz
1ff08e4b20 revset: changed minrev and maxrev implementations to use ordered sets
Performance Benchmarking:

0) max(tip:0)
1) min(0:tip)
2) min(0::)

c6d901b5cf89 (2.9.1 release)

    0) ! wall 0.005699 comb 0.000000 user 0.000000 sys 0.000000 (best of 450)
    1) ! wall 0.005414 comb 0.010000 user 0.010000 sys 0.000000 (best of 493)
    2) ! wall 0.025951 comb 0.030000 user 0.030000 sys 0.000000 (best of 107)

a9da3f4c0086 (public tip at submission time)

    0) ! wall 0.015177 comb 0.020000 user 0.020000 sys 0.000000 (best of 175)
    1) ! wall 0.014779 comb 0.010000 user 0.010000 sys 0.000000 (best of 189)
    2) ! wall 12.345179 comb 12.350000 user 12.350000 sys 0.000000 (best of 3)

Current patches:

    0) ! wall 0.001911 comb 0.000000 user 0.000000 sys 0.000000 (best of 1357)
    1) ! wall 0.001943 comb 0.010000 user 0.010000 sys 0.000000 (best of 1406)
    2) ! wall 0.000405 comb 0.000000 user 0.000000 sys 0.000000 (best of 6761)
2014-02-18 11:35:03 -08:00
Lucas Moscovicz
3bb3a9b599 revset: changed addset to extend _orderedsetmixin
Now _addset can use the lazy min and max implementation.
2014-03-14 14:43:44 -07:00
Pierre-Yves David
5b4ec0c02e revset: add a default argument for baseset.__init__
We are now able to create empty baseset using `baseset()` as we are able to
create empty list with `list()`.
2014-03-14 11:41:26 -07:00
Lucas Moscovicz
b693f7e6e2 revset: changed orderedlazyset to also extend _orderedsetmixin
Now orderedlazyset can use the lazy min and max implementation.
2014-03-13 11:36:45 -07:00
Lucas Moscovicz
6cf940b8a2 revset: changed spanset to extend _orderedsetmixin
Now spanset can use the lazy min and max methods implementation.
2014-03-13 11:36:11 -07:00
Lucas Moscovicz
732d8995dd revset: added _orderedsetmixin class
This class has utility methods for any ordered class to get the min and the
max values.
2014-03-12 16:40:18 -07:00
Lucas Moscovicz
829c2686af revset: added min and max methods to baseset and lazyset
This classes have no particular order so they rely on python min() and max()
implementation. This methods will be implemented in every smartset class in
future patches. For other classes there are lazy implementations that can be
made for this methods.
2014-02-19 09:28:17 -08:00
Pierre-Yves David
74abf98daf revset: add documentation and comment for _generatorset
(clean up some old irrelevant comment in the process)
2014-03-14 10:57:04 -07:00
Pierre-Yves David
170d61865e revset: add some documentation for lazyset 2014-03-14 10:55:03 -07:00
Lucas Moscovicz
6f3e54ea87 revset: added documentation and comment for spanset class 2014-03-14 10:59:51 -07:00
Lucas Moscovicz
432476d8c0 revset: changed smartset methods to return ordered addsets
Now when adding two structures that are ordered, they are wrapped into an
_addset and they get added lazily while keeping the order.
2014-03-11 17:25:53 -07:00
Lucas Moscovicz
dd9f8534d9 revset: added isascending and isdescending methods to _addset
This methods are intended to duck-type baseset, so we will still have _addset
as a private class but now we can return it without wrapping it into an
orderedlazyset or a lazyset.

These were the last methods to add for smartset compatibility.
2014-03-14 10:24:09 -07:00
Lucas Moscovicz
c5a9f97171 revset: added __add__ method to _addset
This method is intended to duck-type baseset, so we will still have _addset as a
private class but we will be able to return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:23:54 -07:00
Lucas Moscovicz
a79e6ad5a0 revset: added __sub__ mehtod to _addset
This method is intended to duck-type baseset, so we will still have _addset as a
private class but now will be able to return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:22:51 -07:00
Lucas Moscovicz
02e069f77d revset: added __and__ method to _addset
This method is intended to duck-type baseset, so we will still have _addset as a
private class but  we will be able to return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:22:29 -07:00
Lucas Moscovicz
73a28cdab8 revset: added ascending and descending methods to _addset
This methods are intended to duck-type baseset, so we will still have _addset
as a private class but will be able return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:21:56 -07:00
Lucas Moscovicz
e603775f94 revset: added filter method to _addset
This method is intended to duck-type baseset, so we will still have _addset
as a private class but we will be able return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-13 19:12:36 -07:00
Lucas Moscovicz
8adde22fdb revset: added comments to all methods needed to duck-type from baseset
All this methods are required to duck-type for any class that works as a smart
set.
2014-03-14 09:18:14 -07:00
Lucas Moscovicz
23a1573060 revset: use more explicit argument names for baseset methods
Use other instead of x and condition instead of l
2014-03-14 10:10:18 -07:00
Lucas Moscovicz
1e32ffe0b9 revset: added isascending and isdescending methods to smartset classes
This methods state if the class is sorted in an ascending or descending order

We need this to implement methods based on order on smartset classes in order
to be able to create new objects with a given order.

We cannot just rely on a simple boolean since unordered set are neither
ascending nor descending.
2014-03-11 17:09:23 -07:00
Lucas Moscovicz
8004a27cbf revset: added sort method in addset
We need this method to duck-type generatorset since this class is not going to
be used outside revset.py and we don't need to duck-type baseset.

This sort method will only do something when the addset is not already sorted
or is not sorted in the way we want it to be.
2014-03-11 17:03:43 -07:00
Lucas Moscovicz
62c7bb9117 revset: added reverse method to addset
This method is needed to duck type generatorset.
2014-03-13 18:57:30 -07:00
Lucas Moscovicz
e5f79a44be revset: changed _iterator() method on addset to work with a given order
If the two collections are in ascending order, yield their values in an
ordered way by iterating both at the same time and picking the values to
yield.
2014-03-13 13:29:04 -07:00
Lucas Moscovicz
f2b80f803a revset: changed _iterator() in addset to use the generated list when available
Now when all the elements have been generated, the iterator will just use the
generated list instead of going through all the elements again.
2014-03-13 14:51:04 -07:00
Lucas Moscovicz
1a5e79571b revset: added cached generated list to addset
This way when all the values have been generated the list can be sorted
without having to generate them all again.
2014-03-11 16:59:42 -07:00
Lucas Moscovicz
67d42c8519 revset: changed sort method to use native sort implementation of smartsets
When sort is done by revision or reversed revision number it can just call
sort on the set and doesn't have to iterate it all over again.
2014-03-13 17:15:21 -07:00
Lucas Moscovicz
6da2a5ca22 revset: fixed sorting issue with spanset
When a spanset was being sorted it didn't take into account it's current
state (ascending or descending) and it reversed itself everytime the reverse
parameter was True.

This is not yet used but it will be as soon as the sort revset is changed to
directly use the structures sort method.
2014-03-13 17:16:58 -07:00
Lucas Moscovicz
edbf51ad8f revset: added __nonzero__ method to spanset class
Implemented it in a lazy way, just look for the first non-filtered revision
and return True if there's any revision at all.
2014-03-14 09:07:59 -07:00
Lucas Moscovicz
04e9ab0a9b revset: optimized sort method in lazyset class
We are taking advantage of the smartset classes sort method when it exists and
converting the set to a baseset otherwise.
2014-03-06 09:41:47 -08:00
Durham Goode
f906635299 revset: improve head revset performance
Previously the head() revset would iterate over every item in the subset and
check if it was a head.  Since the subset is often the entire repo, this was
slow on large repos. Now we iterate over each item in the head list and check if
it's in the subset, which results in much less work.

hg log -r 'head()' on a large repo:
Before: 0.95s
After: 0.28s
2014-03-13 13:47:21 -07:00
Lucas Moscovicz
36702af6f9 revset: added ascending attribute to addset class
In case both collections are in an ascending/descending order then we will be
able to iterate them lazily while keeping the order.
2014-03-11 16:52:15 -07:00
Lucas Moscovicz
7da57d658a revset: added set method to addset to duck type generatorset
Since this class is only going to be used inside revset.py (it does not duck
type baseset) it needs to duck type only a few more methods for the next
patches.
2014-03-10 10:49:04 -07:00
Matt Mackall
064d711c69 revsets: backout f497f83593d8 due to performance regressions 2014-03-13 14:34:32 -05:00
Lucas Moscovicz
efb319fb76 revset: made addset a private class
This class is not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:20:26 -07:00
Lucas Moscovicz
a50567190d revset: made descgeneratorset a private class
This class is not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:19:46 -07:00
Lucas Moscovicz
e6b1cc49b9 revset: made ascgeneratorset a private class
This class is not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:18:54 -07:00
Lucas Moscovicz
7e33d4c691 revset: made generatorset a private class
This class are not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:07:38 -07:00
Lucas Moscovicz
2c2b32444e revset: added sort methods to generatorsets
Method needed to propagate sort calls amongst lazy structures.
The generated list (stored in the object) is sorted.

If the generated list did not contain all elements from the generator, we
take care of that before sorting the list.
2014-02-24 16:36:17 -08:00