Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/deltas.py @ 40709:39d29542fe40
sparse-revlog: put the native implementation of slicechunktodensity to use
When possible, the C implementation of delta chain slicing will be used.
providing a large boost in performance for this operation.
To take a practical example of restoring manifest revision '59547c40bc4c' for
a reference NetBeans repository (using sparse-revlog). The media time of the
step `slice-sparse-chain` of `perfrevlogrevision` improve from 0.660 ms to
0.098 ms;
The full series move delta chain slicing from 1.120 ms to 0.098 ms;
Implementing _slicechunktosize into C would yield further improvements.
However, the performance seems good enough for now.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 15 Nov 2018 11:11:38 +0100 |
parents | 2eb48aa0acce |
children | f960c51eebf3 |
comparison
equal
deleted
inserted
replaced
40708:f2342483f7a6 | 40709:39d29542fe40 |
---|---|
42 """data is an list of revision payload boundaries""" | 42 """data is an list of revision payload boundaries""" |
43 self._data = data | 43 self._data = data |
44 self._srdensitythreshold = density | 44 self._srdensitythreshold = density |
45 self._srmingapsize = mingap | 45 self._srmingapsize = mingap |
46 self._snapshot = set(snapshot) | 46 self._snapshot = set(snapshot) |
47 self.index = None | |
47 | 48 |
48 def start(self, rev): | 49 def start(self, rev): |
49 if rev == 0: | 50 if rev == 0: |
50 return 0 | 51 return 0 |
51 return self._data[rev - 1] | 52 return self._data[rev - 1] |
118 """ | 119 """ |
119 if targetsize is not None: | 120 if targetsize is not None: |
120 targetsize = max(targetsize, revlog._srmingapsize) | 121 targetsize = max(targetsize, revlog._srmingapsize) |
121 # targetsize should not be specified when evaluating delta candidates: | 122 # targetsize should not be specified when evaluating delta candidates: |
122 # * targetsize is used to ensure we stay within specification when reading, | 123 # * targetsize is used to ensure we stay within specification when reading, |
123 for chunk in _slicechunktodensity(revlog, revs, | 124 densityslicing = getattr(revlog.index, 'slicechunktodensity', None) |
124 revlog._srdensitythreshold, | 125 if densityslicing is None: |
125 revlog._srmingapsize): | 126 densityslicing = lambda x, y, z: _slicechunktodensity(revlog, x, y, z) |
127 for chunk in densityslicing(revs, | |
128 revlog._srdensitythreshold, | |
129 revlog._srmingapsize): | |
126 for subchunk in _slicechunktosize(revlog, chunk, targetsize): | 130 for subchunk in _slicechunktosize(revlog, chunk, targetsize): |
127 yield subchunk | 131 yield subchunk |
128 | 132 |
129 def _slicechunktosize(revlog, revs, targetsize=None): | 133 def _slicechunktosize(revlog, revs, targetsize=None): |
130 """slice revs to match the target size | 134 """slice revs to match the target size |