Mercurial > public > mercurial-scm > hg-stable
diff contrib/perf.py @ 41579:bf7fb97aecf1
branchmap: make branchcache responsible for reading
Encapsulate reading in a classmethod, to make it clear what kind of object is
being handled.
This is part of a stack of refactoring changes to help performance improvements
down the line.
Differential Revision: https://phab.mercurial-scm.org/D5635
author | Martijn Pieters <mj@octobus.net> |
---|---|
date | Mon, 21 Jan 2019 16:04:48 +0000 |
parents | d1a273074f62 |
children | 328ca3b9e545 |
line wrap: on
line diff
--- a/contrib/perf.py Mon Feb 04 09:10:07 2019 -0800 +++ b/contrib/perf.py Mon Jan 21 16:04:48 2019 +0000 @@ -2409,10 +2409,15 @@ # add unfiltered allfilters.append(None) - branchcacheread = safeattrsetter(branchmap, b'read') + if util.safehasattr(branchmap.branchcache, 'fromfile'): + branchcacheread = safeattrsetter(branchmap.branchcache, b'fromfile') + branchcacheread.set(classmethod(lambda *args: None)) + else: + # older versions + branchcacheread = safeattrsetter(branchmap, b'read') + branchcacheread.set(lambda *args: None) branchcachewrite = safeattrsetter(branchmap.branchcache, b'write') - branchcacheread.set(lambda repo: None) - branchcachewrite.set(lambda bc, repo: None) + branchcachewrite.set(lambda *args: None) try: for name in allfilters: printname = name @@ -2556,9 +2561,15 @@ repo.branchmap() # make sure we have a relevant, up to date branchmap + try: + fromfile = branchmap.branchcache.fromfile + except AttributeError: + # older versions + fromfile = branchmap.read + currentfilter = filter # try once without timer, the filter may not be cached - while branchmap.read(repo) is None: + while fromfile(repo) is None: currentfilter = subsettable.get(currentfilter) if currentfilter is None: raise error.Abort(b'No branchmap cached for %s repo' @@ -2569,7 +2580,7 @@ if clearrevlogs: clearchangelog(repo) def bench(): - branchmap.read(repo) + fromfile(repo) timer(bench, setup=setup) fm.end()