Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 21750:4ab287c2d337 stable
revlog: hold a private reference to self._cache
This keeps other threads from modifying self._cache out from under us.
With this and the previous fix, 'hg serve' survives 100k hits with siege.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 13 Jun 2014 14:17:14 -0500 |
parents | f13728d59c0e |
children | e250a482478e |
comparison
equal
deleted
inserted
replaced
21749:f13728d59c0e | 21750:4ab287c2d337 |
---|---|
970 node = self.node(rev) | 970 node = self.node(rev) |
971 else: | 971 else: |
972 node = nodeorrev | 972 node = nodeorrev |
973 rev = None | 973 rev = None |
974 | 974 |
975 _cache = self._cache # grab local copy of cache to avoid thread race | |
975 cachedrev = None | 976 cachedrev = None |
976 if node == nullid: | 977 if node == nullid: |
977 return "" | 978 return "" |
978 if self._cache: | 979 if _cache: |
979 if self._cache[0] == node: | 980 if _cache[0] == node: |
980 return self._cache[2] | 981 return _cache[2] |
981 cachedrev = self._cache[1] | 982 cachedrev = _cache[1] |
982 | 983 |
983 # look up what we need to read | 984 # look up what we need to read |
984 text = None | 985 text = None |
985 if rev is None: | 986 if rev is None: |
986 rev = self.rev(node) | 987 rev = self.rev(node) |
1004 iterrev -= 1 | 1005 iterrev -= 1 |
1005 e = index[iterrev] | 1006 e = index[iterrev] |
1006 | 1007 |
1007 if iterrev == cachedrev: | 1008 if iterrev == cachedrev: |
1008 # cache hit | 1009 # cache hit |
1009 text = self._cache[2] | 1010 text = _cache[2] |
1010 else: | 1011 else: |
1011 chain.append(iterrev) | 1012 chain.append(iterrev) |
1012 chain.reverse() | 1013 chain.reverse() |
1013 | 1014 |
1014 # drop cache to save memory | 1015 # drop cache to save memory |