revlog: make _chunkcache access atomic stable
authorMatt Mackall <mpm@selenic.com>
Fri, 13 Jun 2014 14:16:03 -0500
branchstable
changeset 21749 f13728d59c0e
parent 21748 8621125a1718
child 21750 4ab287c2d337
revlog: make _chunkcache access atomic With this and related fixes, 'hg serve' survived 100000 hits with siege.
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