comparison mercurial/revlog.py @ 27650:e7222d326ea2

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 22 Nov 2015 17:57:35 -0800
parents 6446e9b37c8b
children a9e010cd66e1
comparison
equal deleted inserted replaced
27649:6446e9b37c8b 27650:e7222d326ea2
1120 buffer = util.buffer 1120 buffer = util.buffer
1121 1121
1122 l = [] 1122 l = []
1123 ladd = l.append 1123 ladd = l.append
1124 1124
1125 # preload the cache
1126 try: 1125 try:
1127 while True: 1126 offset, data = self._chunkraw(revs[0], revs[-1], df=df)
1128 # ensure that the cache doesn't change out from under us
1129 _cache = self._chunkcache
1130 self._chunkraw(revs[0], revs[-1], df=df)[1]
1131 if _cache == self._chunkcache:
1132 break
1133 offset, data = _cache
1134 except OverflowError: 1127 except OverflowError:
1135 # issue4215 - we can't cache a run of chunks greater than 1128 # issue4215 - we can't cache a run of chunks greater than
1136 # 2G on Windows 1129 # 2G on Windows
1137 return [self._chunk(rev, df=df) for rev in revs] 1130 return [self._chunk(rev, df=df) for rev in revs]
1138 1131