[PATCH 09 of 10] deltas: skip if projected compressed size is bigger than previous snapshot

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


# HG changeset patch
# User Valentin Gatien-Baron <vgatien-baron at janestreet.com>
# Date 1548107191 -3600
#      Mon Jan 21 22:46:31 2019 +0100
# Node ID 2cf494071b512e69877589bf740117a642d26330
# Parent  f724b0c7cef6c2069c03587d2712a8628566aef1
# EXP-Topic delta-extra
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2cf494071b51
deltas: skip if projected compressed size is bigger than previous snapshot

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(snapshotⁿ) > size(snapshotⁿ⁺¹)` constraint. 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.010646 seconds
after:   2.609307 seconds

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -966,6 +966,8 @@ class deltacomputer(object):
             snapshotlimit = revinfo.textlen >> snapshotdepth
             if snapshotlimit < lowestrealisticdeltalen:
                 return None
+            if revlog.length(base) < 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