[PATCH 8 of 8] delta: reuse _findsnapshot call from previous stage
Boris Feld
boris.feld at octobus.net
Mon Dec 17 07:00:50 EST 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1545041567 -3600
# Mon Dec 17 11:12:47 2018 +0100
# Node ID 244ae450e30f3e352a56c62ade6a5759cb23e05f
# Parent 3294c80c1c71ab738a46bba671ee8e094a479fc6
# EXP-Topic sparse-revlog-corner-cases
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 244ae450e30f
delta: reuse _findsnapshot call from previous stage
Two different stage of the sparse-revlog logic needs the _findsnapshot data.
To avoid recomputing it twice, make it possible to reuse the first computation
in the second step.
example affected manifest write
before: 0.067141s
after: 0.064252s (-5%)
(total gain since start of series: 95%)
diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -701,7 +701,8 @@ def _refinedgroups(revlog, p1, p2, cache
if good is not None:
yield None
return
- for candidates in _rawgroups(revlog, p1, p2, cachedelta):
+ snapshots = collections.defaultdict(list)
+ for candidates in _rawgroups(revlog, p1, p2, cachedelta, snapshots):
good = yield candidates
if good is not None:
break
@@ -722,12 +723,8 @@ def _refinedgroups(revlog, p1, p2, cache
break
good = yield (base,)
# refine snapshot up
- #
- # XXX the _findsnapshots call can be expensive and is "duplicated" with
- # the one done in `_rawgroups`. Once we start working on performance,
- # we should make the two logics share this computation.
- snapshots = collections.defaultdict(list)
- _findsnapshots(revlog, snapshots, good + 1)
+ if not snapshots:
+ _findsnapshots(revlog, snapshots, good + 1)
previous = None
while good != previous:
previous = good
@@ -737,7 +734,7 @@ def _refinedgroups(revlog, p1, p2, cache
# we have found nothing
yield None
-def _rawgroups(revlog, p1, p2, cachedelta):
+def _rawgroups(revlog, p1, p2, cachedelta, snapshots=None):
"""Provides group of revision to be tested as delta base
This lower level function focus on emitting delta theorically interresting
@@ -767,7 +764,9 @@ def _rawgroups(revlog, p1, p2, cachedelt
yield parents
if sparse and parents:
- snapshots = collections.defaultdict(list) # map: base-rev: snapshot-rev
+ if snapshots is None:
+ # map: base-rev: snapshot-rev
+ snapshots = collections.defaultdict(list)
# See if we can use an existing snapshot in the parent chains to use as
# a base for a new intermediate-snapshot
#
More information about the Mercurial-devel
mailing list