Patchwork [04,of,14] sparse-revlog: fast-path before computing payload size

login
register
mail settings
Submitter Boris Feld
Date Nov. 12, 2018, 9:55 a.m.
Message ID <3bdd984df153304a956d.1542016539@localhost.localdomain>
Download mbox | patch
Permalink /patch/36511/
State Accepted
Headers show

Comments

Boris Feld - Nov. 12, 2018, 9:55 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1541687398 -3600
#      Thu Nov 08 15:29:58 2018 +0100
# Node ID 3bdd984df153304a956d31d2f3fbc3cd7f0e41c2
# Parent  c8eba56f115019badd26223e504ca4899210075a
# EXP-Topic sparse-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 3bdd984df153
sparse-revlog: fast-path before computing payload size

In this fast-path case, we do not need to compute the full delta chain
payload. Since it comes with a significant cost, we avoid doing so if
possible.

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -257,13 +257,13 @@  def _slicechunktodensity(revlog, revs, t
         return
 
     deltachainspan = segmentspan(revlog, revs)
-    chainpayload = sum(length(r) for r in revs)
 
     if deltachainspan < mingapsize:
         yield revs
         return
 
     readdata = deltachainspan
+    chainpayload = sum(length(r) for r in revs)
 
     if deltachainspan:
         density = chainpayload / float(deltachainspan)