# HG changeset patch # User Pierre-Yves David # Date 2022-11-06 22:53:17 # Node ID c261a628e5252f373f78ed40a0702d794a91a1de # Parent 40e24d82b5133a6ac689e14667ce7d6dcd4a482e 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. diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py --- a/mercurial/revlogutils/deltas.py +++ b/mercurial/revlogutils/deltas.py @@ -664,6 +664,7 @@ def _candidategroups( cachedelta, excluded_bases=None, target_rev=None, + snapshot_cache=None, ): """Provides group of revision to be tested as delta base @@ -689,6 +690,7 @@ def _candidategroups( p1, p2, cachedelta, + snapshot_cache=snapshot_cache, ) while True: temptative = candidates.send(good) @@ -799,7 +801,7 @@ def _candidategroups( yield None -def _refinedgroups(revlog, p1, p2, cachedelta): +def _refinedgroups(revlog, p1, p2, cachedelta, snapshot_cache=None): good = None # First we try to reuse a the delta contained in the bundle. # (or from the source revlog) @@ -819,8 +821,8 @@ def _refinedgroups(revlog, p1, p2, cache debug_info['cached-delta.accepted'] += 1 yield None return - # XXX cache me higher - snapshot_cache = SnapshotCache() + if snapshot_cache is None: + snapshot_cache = SnapshotCache() groups = _rawgroups( revlog, p1, @@ -1053,6 +1055,7 @@ class deltacomputer: self._write_debug = write_debug self._debug_search = debug_search self._debug_info = debug_info + self._snapshot_cache = SnapshotCache() def buildtext(self, revinfo, fh): """Builds a fulltext version of a revision @@ -1265,6 +1268,7 @@ class deltacomputer: cachedelta, excluded_bases, target_rev, + snapshot_cache=self._snapshot_cache, ) candidaterevs = next(groups) while candidaterevs is not None: