Mercurial > hg
changeset 27258:beda2c9dbbff
repoview: bypass changelog method to computed cache key
Getting the data necessary for the cache key using the changelog/revlog method
adds a significant overhead. Given how simple the underlying implementation is
and often this code is ran, it makes sense to violate layering and directly
compute the data.
Testing `hg log` on Mozilla-central, this reduce the time spent on changelog
cache validation by an extra half:
before: 12.2s of 69s
after: 6.1s of 62s
Total speed up from this patch and it's parent is 3x
(With stupid python profiler overhead)
The global speedup without profiler overhead is still there,
Before: 51s
After: 39s (-23%)
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 04 Dec 2015 14:22:15 -0800 |
parents | 49a76d3d43b1 |
children | 290b41913d9f |
files | mercurial/repoview.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/repoview.py Fri Dec 04 14:04:24 2015 -0800 +++ b/mercurial/repoview.py Fri Dec 04 14:22:15 2015 -0800 @@ -300,13 +300,16 @@ # some cache may be implemented later unfi = self._unfilteredrepo unfichangelog = unfi.changelog + # bypass call to changelog.method + unfiindex = unfichangelog.index + unfilen = len(unfiindex) - 1 + unfinode = unfiindex[unfilen - 1][7] + revs = filterrevs(unfi, self.filtername) cl = self._clcache - newkey = (len(unfichangelog), unfichangelog.tip(), hash(revs), - unfichangelog._delayed) - if cl is not None: - if newkey != self._clcachekey: - cl = None + newkey = (unfilen, unfinode, hash(revs), unfichangelog._delayed) + if cl is not None and newkey != self._clcachekey: + cl = None # could have been made None by the previous if if cl is None: cl = copy.copy(unfichangelog)