reachableroots: default to the C implementation

This patch is part of a series of patches to speed up the computation of
revset.reachableroots by introducing a C implementation. The main motivation is to
speed up smartlog on big repositories. At the end of the series, on our big
repositories the computation of reachableroots is 10-50x faster and smartlog on is
2x-5x faster.

Before this patch, reachableroots was computed in pure Python by default. This
patch makes the C implementation the default and provides a speedup for
reachableroots.
This commit is contained in:
Laurent Charignon 2015-08-06 22:11:20 -07:00
parent 1268f45eae
commit 2884b0bddb

View File

@ -87,7 +87,7 @@ def _revdescendants(repo, revs, followfirst):
return generatorset(iterate(), iterasc=True)
def reachableroots(repo, roots, heads, includepath=False):
def reachablerootspure(repo, minroot, roots, heads, includepath):
"""return (heads(::<roots> and ::<heads>))
If includepath is True, return (<roots>::<heads>)."""
@ -97,10 +97,6 @@ def reachableroots(repo, roots, heads, includepath=False):
visit = list(heads)
reachable = set()
seen = {}
# XXX this should be 'parentset.min()' assuming 'parentset' is a smartset
# (and if it is not, it should.)
minroot = min(roots)
roots = set(roots)
# prefetch all the things! (because python is slow)
reached = reachable.add
dovisit = visit.append
@ -128,6 +124,22 @@ def reachableroots(repo, roots, heads, includepath=False):
reached(rev)
return baseset(sorted(reachable))
def reachableroots(repo, roots, heads, includepath=False):
"""return (heads(::<roots> and ::<heads>))
If includepath is True, return (<roots>::<heads>)."""
if not roots:
return baseset()
# XXX this should be 'parentset.min()' assuming 'parentset' is a smartset
# (and if it is not, it should.)
minroot = min(roots)
roots = set(roots)
heads = list(heads)
try:
return repo.changelog.reachableroots(minroot, heads, roots, includepath)
except AttributeError:
return reachablerootspure(repo, minroot, roots, heads, includepath)
elements = {
# token-type: binding-strength, primary, prefix, infix, suffix
"(": (21, None, ("group", 1, ")"), ("func", 1, ")"), None),