# HG changeset patch # User Matt Mackall # Date 1185241448 18000 # Node ID 14486eea8e7a3d4d7e7e1af36405fa96903bfc25 # Parent 8d30004ada40af8deee9e9e0a925bf837db98114 revlog: speed up chunkcache - use a reasonable cache size - avoid an extra copy when we pull in big revs diff -r 8d30004ada40 -r 14486eea8e7a mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py Mon Jul 23 20:44:08 2007 -0500 +++ b/mercurial/bundlerepo.py Mon Jul 23 20:44:08 2007 -0500 @@ -77,7 +77,7 @@ # not against rev - 1 # XXX: could use some caching if not self.bundle(rev): - return revlog.revlog.chunk(self, rev, df, cachelen) + return revlog.revlog.chunk(self, rev, df) self.bundlefile.seek(self.start(rev)) return self.bundlefile.read(self.length(rev)) diff -r 8d30004ada40 -r 14486eea8e7a mercurial/revlog.py --- a/mercurial/revlog.py Mon Jul 23 20:44:08 2007 -0500 +++ b/mercurial/revlog.py Mon Jul 23 20:44:08 2007 -0500 @@ -838,16 +838,15 @@ """apply a list of patches to a string""" return mdiff.patches(t, pl) - def chunk(self, rev, df=None, cachelen=4096): + def chunk(self, rev, df=None): start, length = self.start(rev), self.length(rev) - inline = self._inline - if inline: + if self._inline: start += (rev + 1) * self._io.size end = start + length def loadcache(df): - cache_length = max(cachelen, length) # 4k + cache_length = max(65536, length) if not df: - if inline: + if self._inline: df = self.opener(self.indexfile) else: df = self.opener(self.datafile) @@ -866,7 +865,12 @@ loadcache(df) offset = 0 - return decompress(self._chunkcache[1][offset:offset + length]) + # avoid copying large chunks + c = self._chunkcache[1] + if len(c) > length: + c = c[offset:offset + length] + + return decompress(c) def delta(self, node): """return or calculate a delta between a node and its predecessor"""