# HG changeset patch # User Boris Feld <boris.f...@octobus.net> # Date 1542832522 0 # Wed Nov 21 20:35:22 2018 +0000 # Node ID 03c3522ed8a678695eba5a0dc7612236fbdfb47b # Parent 3a9ca368b2362f2304895a9a238abccdd4aee633 # EXP-Topic perf-branchmap # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 03c3522ed8a6 perf: rely on repoview for perfbranchmapupdate
Using 'repoview' matching the base and target subset make the benchmark more realistic. It also unlocks optimization to make the command initialization faster. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -2247,8 +2247,10 @@ def perfbranchmapupdate(ui, repo, base=( $ hg perfbranchmapupdate --base 'stable' --target 'default' """ from mercurial import branchmap + from mercurial import repoview opts = _byteskwargs(opts) timer, fm = gettimer(ui, opts) + unfi = repo.unfiltered() x = [None] # used to pass data between closure # we use a `list` here to avoid possible side effect from smartset @@ -2271,21 +2273,43 @@ def perfbranchmapupdate(ui, repo, base=( newrevs = list(alltargetrevs.difference(allbaserevs)) newrevs.sort() + allrevs = frozenset(unfi.changelog.revs()) + basefilterrevs = frozenset(allrevs.difference(allbaserevs)) + targetfilterrevs = frozenset(allrevs.difference(alltargetrevs)) + + def basefilter(repo, visibilityexceptions=None): + return basefilterrevs + + def targetfilter(repo, visibilityexceptions=None): + return targetfilterrevs + msg = 'benchmark of branchmap with %d revisions with %d new ones\n' ui.status(msg % (len(allbaserevs), len(newrevs))) + if targetfilterrevs: + msg = '(%d revisions still filtered)\n' + ui.status(msg % len(targetfilterrevs)) - if True: + try: + repoview.filtertable['__perf_branchmap_update_base'] = basefilter + repoview.filtertable['__perf_branchmap_update_target'] = targetfilter + + baserepo = repo.filtered('__perf_branchmap_update_base') + targetrepo = repo.filtered('__perf_branchmap_update_target') + base = branchmap.branchcache() - base.update(repo, allbaserevs) + base.update(baserepo, allbaserevs) def setup(): x[0] = base.copy() def bench(): - x[0].update(repo, newrevs) + x[0].update(targetrepo, newrevs) timer(bench, setup=setup) fm.end() + finally: + repoview.filtertable.pop('__perf_branchmap_update_base', None) + repoview.filtertable.pop('__perf_branchmap_update_target', None) @command(b'perfbranchmapload', [ (b'f', b'filter', b'', b'Specify repoview filter'), _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel