comparison mercurial/revset.py @ 25622:85294076adce

revset: make use of natively-computed set for 'draft()' and 'secret()' If the computation of a set for each phase (done in C) is available, we use it directly instead of applying a simple filter. This give a massive speed-up in the vast majority of cases. On my mercurial repo with about 15000 out of 40000 draft changesets: revset: draft() plain min first last 0) 0.011201 0.019950 0.009844 0.000074 1) 0.000284 2% 0.000312 1% 0.000314 3% 0.000315 x4.3 Bad performance for "last" come from the handling of the 15000 elements set (memory allocation, filtering hidden changesets (99% of it) etc. compared to applying the filter only on a handfuld of revisions (the first draft changesets being close of tip). This is not seen as an issue since: * Timing is still pretty good and in line with all the other one, * Current user of Vanilla Mercurial will not have 1/3 of their repo draft, This bad effect disappears when phase's set is smaller. (about 200 secrets): revset: secret() plain min first last 0) 0.011181 0.022228 0.010851 0.000452 1) 0.000058 0% 0.000084 0% 0.000087 0% 0.000087 19%
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 10 Jun 2015 19:18:51 -0700
parents 21a874693619
children c88082baf693
comparison
equal deleted inserted replaced
25621:21a874693619 25622:85294076adce
1462 ps -= set([node.nullrev]) 1462 ps -= set([node.nullrev])
1463 return subset & ps 1463 return subset & ps
1464 1464
1465 def _phase(repo, subset, target): 1465 def _phase(repo, subset, target):
1466 """helper to select all rev in phase <target>""" 1466 """helper to select all rev in phase <target>"""
1467 phase = repo._phasecache.phase 1467 repo._phasecache.loadphaserevs(repo) # ensure phase's sets are loaded
1468 condition = lambda r: phase(repo, r) == target 1468 if repo._phasecache._phasesets:
1469 return subset.filter(condition, cache=False) 1469 s = repo._phasecache._phasesets[target] - repo.changelog.filteredrevs
1470 s = baseset(s)
1471 s.sort() # set are non ordered, so we enforce ascending
1472 return subset & s
1473 else:
1474 phase = repo._phasecache.phase
1475 condition = lambda r: phase(repo, r) == target
1476 return subset.filter(condition, cache=False)
1470 1477
1471 def draft(repo, subset, x): 1478 def draft(repo, subset, x):
1472 """``draft()`` 1479 """``draft()``
1473 Changeset in draft phase.""" 1480 Changeset in draft phase."""
1474 # i18n: "draft" is a keyword 1481 # i18n: "draft" is a keyword