# HG changeset patch # User Matt Mackall # Date 1402686963 18000 # Node ID f13728d59c0e146060649986041af35ec7b3f8c9 # Parent 8621125a1718380d230eb4d052edeed66f2a8e5a revlog: make _chunkcache access atomic With this and related fixes, 'hg serve' survived 100000 hits with siege. diff -r 8621125a1718 -r f13728d59c0e mercurial/revlog.py --- a/mercurial/revlog.py Mon Jun 09 10:34:21 2014 -0700 +++ b/mercurial/revlog.py Fri Jun 13 14:16:03 2014 -0500 @@ -919,8 +919,13 @@ # preload the cache try: - self._chunkraw(revs[0], revs[-1]) - offset, data = self._chunkcache + while 1: + # ensure that the cache doesn't change out from under us + _cache = self._chunkcache + self._chunkraw(revs[0], revs[-1]) + if _cache == self._chunkcache: + break + offset, data = _cache except OverflowError: # issue4215 - we can't cache a run of chunks greater than # 2G on Windows