Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20895:f52e4ca93529
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).
author | Durham Goode <durham@fb.com> |
---|---|
date | Mon, 31 Mar 2014 16:03:34 -0700 |
parents | 04e1596d5dbd |
children | a05d694599f9 |
comparison
equal
deleted
inserted
replaced
20894:04e1596d5dbd | 20895:f52e4ca93529 |
---|---|
1478 | 1478 |
1479 def roots(repo, subset, x): | 1479 def roots(repo, subset, x): |
1480 """``roots(set)`` | 1480 """``roots(set)`` |
1481 Changesets in set with no parent changeset in set. | 1481 Changesets in set with no parent changeset in set. |
1482 """ | 1482 """ |
1483 s = getset(repo, baseset(repo.changelog), x).set() | 1483 s = getset(repo, spanset(repo), x).set() |
1484 subset = baseset([r for r in subset if r in s]) | 1484 subset = baseset([r for r in s if r in subset.set()]) |
1485 cs = _children(repo, subset, s) | 1485 cs = _children(repo, subset, s) |
1486 return subset - cs | 1486 return subset - cs |
1487 | 1487 |
1488 def secret(repo, subset, x): | 1488 def secret(repo, subset, x): |
1489 """``secret()`` | 1489 """``secret()`` |