# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 2014-11-12 04:08:19
# Node ID 2b9bc796350423eef9abe8db2a637fe0a5eb7af2
# Parent  426d7f901789f6df2087e36a04ccd40ea45a20ae

revlog: increase I/O bound to 4x the amount of data consumed

This doesn't affect normal clones since they'd be bound by the CPU bound below
anyway -- it does, however, improve generaldelta clones significantly.

This also results in better deltaing for generaldelta clones -- in generaldelta
clones, we calculate deltas with respect to the closest base if it has a higher
revision number than either parent. If the base is on a significantly different
branch, this can result in pointlessly massive deltas. This reduces the number
of bases and hence the number of bad deltas.

Empirically, for a highly branchy repository, this resulted in an improvement
of around 15% to manifest size.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1267,7 +1267,7 @@ class revlog(object):
         #   the amount of I/O we need to do.
         # - 'compresseddeltalen' is the sum of the total size of deltas we need
         #   to apply -- bounding it limits the amount of CPU we consume.
-        if (d is None or dist > textlen * 2 or l > textlen or
+        if (d is None or dist > textlen * 4 or l > textlen or
             compresseddeltalen > textlen * 2 or
             (self._maxchainlen and chainlen > self._maxchainlen)):
             text = buildtext()