Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 19713:c2e27e57d250
revlog: add a fast method for getting a list of chunks
This moves _chunkraw into the loop. Doing that improves revlog decompression --
in particular, manifest decompression -- significantly. For a 20 MB manifest
which is the result of a > 40k delta chain, hg perfmanifest improves from 0.55
seconds to 0.49 seconds.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 06 Sep 2013 16:31:35 -0700 |
parents | 6a411a06cb1f |
children | 0e07c0b5fb1c |
comparison
equal
deleted
inserted
replaced
19712:79e5de2bfa8c | 19713:c2e27e57d250 |
---|---|
851 return self._getchunk(start, length) | 851 return self._getchunk(start, length) |
852 | 852 |
853 def _chunk(self, rev): | 853 def _chunk(self, rev): |
854 return decompress(self._chunkraw(rev, rev)) | 854 return decompress(self._chunkraw(rev, rev)) |
855 | 855 |
856 def _chunks(self, revs): | |
857 '''faster version of [self._chunk(rev) for rev in revs] | |
858 | |
859 Assumes that revs is in ascending order.''' | |
860 start = self.start | |
861 length = self.length | |
862 inline = self._inline | |
863 iosize = self._io.size | |
864 getchunk = self._getchunk | |
865 | |
866 l = [] | |
867 ladd = l.append | |
868 | |
869 for rev in revs: | |
870 chunkstart = start(rev) | |
871 if inline: | |
872 chunkstart += (rev + 1) * iosize | |
873 chunklength = length(rev) | |
874 ladd(decompress(getchunk(chunkstart, chunklength))) | |
875 | |
876 return l | |
877 | |
856 def _chunkbase(self, rev): | 878 def _chunkbase(self, rev): |
857 return self._chunk(rev) | 879 return self._chunk(rev) |
858 | 880 |
859 def _chunkclear(self): | 881 def _chunkclear(self): |
860 self._chunkcache = (0, '') | 882 self._chunkcache = (0, '') |
931 | 953 |
932 self._chunkraw(base, rev) | 954 self._chunkraw(base, rev) |
933 if text is None: | 955 if text is None: |
934 text = str(self._chunkbase(base)) | 956 text = str(self._chunkbase(base)) |
935 | 957 |
936 bins = [self._chunk(r) for r in chain] | 958 bins = self._chunks(chain) |
937 text = mdiff.patches(text, bins) | 959 text = mdiff.patches(text, bins) |
938 | 960 |
939 text = self._checkhash(text, node, rev) | 961 text = self._checkhash(text, node, rev) |
940 | 962 |
941 self._cache = (node, rev, text) | 963 self._cache = (node, rev, text) |