Mercurial > hg
diff mercurial/pure/parsers.py @ 45936:0ce15a8c7b8b
revlog: store new index entries as binary
For a pure-Python unbundle of the current NetBSD test repository, this
results in a 10% peak RSS reduction. Using the C revlog index, it shows
25% peak RSS reduction. This is a direct result of avoiding at least
8 objects per new changeset or 200 Bytes+ on AMD64.
Differential Revision: https://phab.mercurial-scm.org/D9162
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 06 Oct 2020 03:25:15 +0200 |
parents | 7baf5f798ba9 |
children | 89a2afe31e82 |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Wed Nov 11 20:44:45 2020 +0100 +++ b/mercurial/pure/parsers.py Tue Oct 06 03:25:15 2020 +0200 @@ -94,7 +94,8 @@ def append(self, tup): if '_nodemap' in vars(self): self._nodemap[tup[7]] = len(self) - self._extra.append(tup) + data = _pack(indexformatng, *tup) + self._extra.append(data) def _check_index(self, i): if not isinstance(i, int): @@ -107,14 +108,13 @@ return nullitem self._check_index(i) if i >= self._lgt: - return self._extra[i - self._lgt] - index = self._calculate_index(i) - r = struct.unpack(indexformatng, self._data[index : index + indexsize]) - if i == 0: - e = list(r) - type = gettype(e[0]) - e[0] = offset_type(0, type) - return tuple(e) + data = self._extra[i - self._lgt] + else: + index = self._calculate_index(i) + data = self._data[index : index + indexsize] + r = _unpack(indexformatng, data) + if self._lgt and i == 0: + r = (offset_type(0, gettype(r[0])),) + r[1:] return r