changeset 21749:f13728d59c0e stable

revlog: make _chunkcache access atomic With this and related fixes, 'hg serve' survived 100000 hits with siege.
author Matt Mackall <mpm@selenic.com>
date Fri, 13 Jun 2014 14:16:03 -0500
parents 8621125a1718
children 4ab287c2d337
files mercurial/revlog.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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