Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlogutils/deltas.py @ 49795:c261a628e525
delta-find: use a single snapshot cache when applying a group to an object
This will avoid walking the revlog over and over again in some situations.
The difference is hard to show in our current benchmark suite, as the gain is
lower than their overall instability.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 06 Nov 2022 17:53:17 -0500 |
parents | 40e24d82b513 |
children | bcae90c53def |
comparison
equal
deleted
inserted
replaced
49794:40e24d82b513 | 49795:c261a628e525 |
---|---|
662 p1, | 662 p1, |
663 p2, | 663 p2, |
664 cachedelta, | 664 cachedelta, |
665 excluded_bases=None, | 665 excluded_bases=None, |
666 target_rev=None, | 666 target_rev=None, |
667 snapshot_cache=None, | |
667 ): | 668 ): |
668 """Provides group of revision to be tested as delta base | 669 """Provides group of revision to be tested as delta base |
669 | 670 |
670 This top level function focus on emitting groups with unique and worthwhile | 671 This top level function focus on emitting groups with unique and worthwhile |
671 content. See _raw_candidate_groups for details about the group order. | 672 content. See _raw_candidate_groups for details about the group order. |
687 candidates = _refinedgroups( | 688 candidates = _refinedgroups( |
688 revlog, | 689 revlog, |
689 p1, | 690 p1, |
690 p2, | 691 p2, |
691 cachedelta, | 692 cachedelta, |
693 snapshot_cache=snapshot_cache, | |
692 ) | 694 ) |
693 while True: | 695 while True: |
694 temptative = candidates.send(good) | 696 temptative = candidates.send(good) |
695 if temptative is None: | 697 if temptative is None: |
696 break | 698 break |
797 break | 799 break |
798 | 800 |
799 yield None | 801 yield None |
800 | 802 |
801 | 803 |
802 def _refinedgroups(revlog, p1, p2, cachedelta): | 804 def _refinedgroups(revlog, p1, p2, cachedelta, snapshot_cache=None): |
803 good = None | 805 good = None |
804 # First we try to reuse a the delta contained in the bundle. | 806 # First we try to reuse a the delta contained in the bundle. |
805 # (or from the source revlog) | 807 # (or from the source revlog) |
806 # | 808 # |
807 # This logic only applies to general delta repositories and can be disabled | 809 # This logic only applies to general delta repositories and can be disabled |
817 if good is not None: | 819 if good is not None: |
818 if debug_info is not None: | 820 if debug_info is not None: |
819 debug_info['cached-delta.accepted'] += 1 | 821 debug_info['cached-delta.accepted'] += 1 |
820 yield None | 822 yield None |
821 return | 823 return |
822 # XXX cache me higher | 824 if snapshot_cache is None: |
823 snapshot_cache = SnapshotCache() | 825 snapshot_cache = SnapshotCache() |
824 groups = _rawgroups( | 826 groups = _rawgroups( |
825 revlog, | 827 revlog, |
826 p1, | 828 p1, |
827 p2, | 829 p2, |
828 cachedelta, | 830 cachedelta, |
1051 ): | 1053 ): |
1052 self.revlog = revlog | 1054 self.revlog = revlog |
1053 self._write_debug = write_debug | 1055 self._write_debug = write_debug |
1054 self._debug_search = debug_search | 1056 self._debug_search = debug_search |
1055 self._debug_info = debug_info | 1057 self._debug_info = debug_info |
1058 self._snapshot_cache = SnapshotCache() | |
1056 | 1059 |
1057 def buildtext(self, revinfo, fh): | 1060 def buildtext(self, revinfo, fh): |
1058 """Builds a fulltext version of a revision | 1061 """Builds a fulltext version of a revision |
1059 | 1062 |
1060 revinfo: revisioninfo instance that contains all needed info | 1063 revinfo: revisioninfo instance that contains all needed info |
1263 p1r, | 1266 p1r, |
1264 p2r, | 1267 p2r, |
1265 cachedelta, | 1268 cachedelta, |
1266 excluded_bases, | 1269 excluded_bases, |
1267 target_rev, | 1270 target_rev, |
1271 snapshot_cache=self._snapshot_cache, | |
1268 ) | 1272 ) |
1269 candidaterevs = next(groups) | 1273 candidaterevs = next(groups) |
1270 while candidaterevs is not None: | 1274 while candidaterevs is not None: |
1271 dbg_try_rounds += 1 | 1275 dbg_try_rounds += 1 |
1272 if debug_search: | 1276 if debug_search: |