comparison mercurial/repoview.py @ 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 9a09a9cfa503
comparison
equal deleted inserted replaced
27257:49a76d3d43b1 27258:beda2c9dbbff
298 298
299 this changelog must not be used for writing""" 299 this changelog must not be used for writing"""
300 # some cache may be implemented later 300 # some cache may be implemented later
301 unfi = self._unfilteredrepo 301 unfi = self._unfilteredrepo
302 unfichangelog = unfi.changelog 302 unfichangelog = unfi.changelog
303 # bypass call to changelog.method
304 unfiindex = unfichangelog.index
305 unfilen = len(unfiindex) - 1
306 unfinode = unfiindex[unfilen - 1][7]
307
303 revs = filterrevs(unfi, self.filtername) 308 revs = filterrevs(unfi, self.filtername)
304 cl = self._clcache 309 cl = self._clcache
305 newkey = (len(unfichangelog), unfichangelog.tip(), hash(revs), 310 newkey = (unfilen, unfinode, hash(revs), unfichangelog._delayed)
306 unfichangelog._delayed) 311 if cl is not None and newkey != self._clcachekey:
307 if cl is not None: 312 cl = None
308 if newkey != self._clcachekey:
309 cl = None
310 # could have been made None by the previous if 313 # could have been made None by the previous if
311 if cl is None: 314 if cl is None:
312 cl = copy.copy(unfichangelog) 315 cl = copy.copy(unfichangelog)
313 cl.filteredrevs = revs 316 cl.filteredrevs = revs
314 object.__setattr__(self, '_clcache', cl) 317 object.__setattr__(self, '_clcache', cl)