comparison mercurial/revlog.py @ 4988:14486eea8e7a

revlog: speed up chunkcache - use a reasonable cache size - avoid an extra copy when we pull in big revs
author Matt Mackall <mpm@selenic.com>
date Mon, 23 Jul 2007 20:44:08 -0500
parents 8d30004ada40
children 1aaed3d69772
comparison
equal deleted inserted replaced
4987:8d30004ada40 4988:14486eea8e7a
836 836
837 def patches(self, t, pl): 837 def patches(self, t, pl):
838 """apply a list of patches to a string""" 838 """apply a list of patches to a string"""
839 return mdiff.patches(t, pl) 839 return mdiff.patches(t, pl)
840 840
841 def chunk(self, rev, df=None, cachelen=4096): 841 def chunk(self, rev, df=None):
842 start, length = self.start(rev), self.length(rev) 842 start, length = self.start(rev), self.length(rev)
843 inline = self._inline 843 if self._inline:
844 if inline:
845 start += (rev + 1) * self._io.size 844 start += (rev + 1) * self._io.size
846 end = start + length 845 end = start + length
847 def loadcache(df): 846 def loadcache(df):
848 cache_length = max(cachelen, length) # 4k 847 cache_length = max(65536, length)
849 if not df: 848 if not df:
850 if inline: 849 if self._inline:
851 df = self.opener(self.indexfile) 850 df = self.opener(self.indexfile)
852 else: 851 else:
853 df = self.opener(self.datafile) 852 df = self.opener(self.datafile)
854 df.seek(start) 853 df.seek(start)
855 self._chunkcache = (start, df.read(cache_length)) 854 self._chunkcache = (start, df.read(cache_length))
864 offset = start - cache_start 863 offset = start - cache_start
865 else: 864 else:
866 loadcache(df) 865 loadcache(df)
867 offset = 0 866 offset = 0
868 867
869 return decompress(self._chunkcache[1][offset:offset + length]) 868 # avoid copying large chunks
869 c = self._chunkcache[1]
870 if len(c) > length:
871 c = c[offset:offset + length]
872
873 return decompress(c)
870 874
871 def delta(self, node): 875 def delta(self, node):
872 """return or calculate a delta between a node and its predecessor""" 876 """return or calculate a delta between a node and its predecessor"""
873 r = self.rev(node) 877 r = self.rev(node)
874 return self.revdiff(r - 1, r) 878 return self.revdiff(r - 1, r)