# HG changeset patch # User Gregory Szorc # Date 2015-11-23 01:57:35 # Node ID e7222d326ea2a9c7671a08ead1089f15301ff0cf # Parent 6446e9b37c8bfb7f224ddc0bb37b31ef9dc20964 revlog: remove unnecessary cache validation in _chunks Previously, we likely called _chunkraw() multiple times in order to ensure it didn't change out from under us. I'm pretty certain this code had its origins in the days where we attempted to have thread safety of localrepository and thus revlog instances. revlog instances are already not thread safe for writing. And, as of Mercurial 3.6, hgweb uses a separate localrepository instance per request, so there should only be a single thread reading a revlog at a time. We more or less decided that attempting to make classes like revlog thread safe is a lost cause. So, this patch removes thread safety from _chunks. As a result, we make one less call into _chunkraw() when the initial read isn't serviced by the cache. This translates to savings of 4 function calls overall and possibly prevents the creation of an additional buffer view into the cache. I doubt this translates into any real world performance wins because decompression will almost certainly dwarf time spent in _chunks(). But it does make the code simpler, so it is an improvement. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1122,15 +1122,8 @@ class revlog(object): l = [] ladd = l.append - # preload the cache try: - while True: - # ensure that the cache doesn't change out from under us - _cache = self._chunkcache - self._chunkraw(revs[0], revs[-1], df=df)[1] - if _cache == self._chunkcache: - break - offset, data = _cache + offset, data = self._chunkraw(revs[0], revs[-1], df=df) except OverflowError: # issue4215 - we can't cache a run of chunks greater than # 2G on Windows