Mercurial > hg
changeset 40771:58355a1de6b3
perf: start from an existing branchmap if possible
If the --base set if a superset of one of the cached branchmap, we should use as
a starting point. This greatly help the overall runtime of
`hg perfbranchmapupdate`
For example, for a repository with about 500 000 revisions, using this trick
make the command runtime move from about 200 second to about 10 seconds. A 20x
gain.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 21 Nov 2018 21:11:47 +0000 |
parents | b059388d976c |
children | 5cbb74999040 |
files | contrib/perf.py |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/perf.py Wed Nov 21 20:35:22 2018 +0000 +++ b/contrib/perf.py Wed Nov 21 21:11:47 2018 +0000 @@ -2347,8 +2347,22 @@ baserepo = repo.filtered(b'__perf_branchmap_update_base') targetrepo = repo.filtered(b'__perf_branchmap_update_target') - base = branchmap.branchcache() - base.update(baserepo, allbaserevs) + # try to find an existing branchmap to reuse + subsettable = getbranchmapsubsettable() + candidatefilter = subsettable.get(None) + while candidatefilter is not None: + candidatebm = repo.filtered(candidatefilter).branchmap() + if candidatebm.validfor(baserepo): + filtered = repoview.filterrevs(repo, candidatefilter) + missing = [r for r in allbaserevs if r in filtered] + base = candidatebm.copy() + base.update(baserepo, missing) + break + candidatefilter = subsettable.get(candidatefilter) + else: + # no suitable subset where found + base = branchmap.branchcache() + base.update(baserepo, allbaserevs) def setup(): x[0] = base.copy()