[PATCH 08 of 10] deltas: skip if projected compressed size does not match text size constraint

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jun 13 09:23:03 EDT 2019


# HG changeset patch
# User Valentin Gatien-Baron <vgatien-baron at janestreet.com>
# Date 1548107178 -3600
#      Mon Jan 21 22:46:18 2019 +0100
# Node ID f724b0c7cef6c2069c03587d2712a8628566aef1
# Parent  e8b1d87ef22cbfbdcb825d3539b9889cbb8a1245
# EXP-Topic delta-extra
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f724b0c7cef6
deltas: skip if projected compressed size does not match text size constraint

If we have a delta, we check constraints against a lower bound estimate of the
resulting compressed delta. We then checks this projected size against the ½ⁿ
size constraints. This allows to exclude potential base candidates before doing
any expensive computation.

This only apply to the intermediate-snapshot case since this constraint only apply to
them.

For some pathological cases of a private repository this step provide a
further performance boost (timing from `hg perfrevlogwrite`):

before:  3.145906 seconds
after:   3.010646 seconds

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -960,6 +960,12 @@ class deltacomputer(object):
                 delta = revinfo.cachedelta[1]
         if delta is None:
             delta = self._builddeltadiff(base, revinfo, fh)
+        # snapshotdept need to be neither None nor 0 level snapshot
+        if revlog.upperboundcomp is not None and snapshotdepth:
+            lowestrealisticdeltalen = len(delta) // revlog.upperboundcomp
+            snapshotlimit = revinfo.textlen >> snapshotdepth
+            if snapshotlimit < lowestrealisticdeltalen:
+                return None
         header, data = revlog.compress(delta)
         deltalen = len(header) + len(data)
         offset = revlog.end(len(revlog) - 1)


More information about the Mercurial-devel mailing list