# HG changeset patch # User Valentin Gatien-Baron # Date 2019-01-21 21:46:31 # Node ID 9b5fbe5ead8948f41528d6ace0c23408457290aa # Parent c1c1872d25d18ec33ff0f62ef4ed516f5d3023b2 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)