[PATCH] debugrevlog: also display the largest delta chain span

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Jun 25 12:43:23 UTC 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1498174690 -7200
#      Fri Jun 23 01:38:10 2017 +0200
# Node ID 97720b4842c41e21c94302bba10c256530e17281
# Parent  a3a36bcf122e2ea4edbbe4ac44da59446cf0ee07
# EXP-Topic manifest
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 97720b4842c4
debugrevlog: also display the largest delta chain span

Mercurial read all data between the base of the chain and the last delta when
restoring content (including unrelated delta). To monitor this, we add data
about the size of the "delta chain span" to debugrevlog.

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1737,6 +1737,8 @@ def debugrevlog(ui, repo, file_=None, **
     nump1prev = 0
     nump2prev = 0
     chainlengths = []
+    chainbases = []
+    chainspans = []
 
     datasize = [None, 0, 0]
     fullsize = [None, 0, 0]
@@ -1762,10 +1764,16 @@ def debugrevlog(ui, repo, file_=None, **
         size = r.length(rev)
         if delta == nullrev:
             chainlengths.append(0)
+            chainbases.append(r.start(rev))
+            chainspans.append(size)
             numfull += 1
             addsize(size, fullsize)
         else:
             chainlengths.append(chainlengths[delta] + 1)
+            baseaddr = chainbases[delta]
+            revaddr = r.start(rev)
+            chainbases.append(baseaddr)
+            chainspans.append((revaddr - baseaddr) + size)
             addsize(size, deltasize)
             if delta == rev - 1:
                 numprev += 1
@@ -1811,6 +1819,7 @@ def debugrevlog(ui, repo, file_=None, **
     totalsize = fulltotal + deltatotal
     avgchainlen = sum(chainlengths) / numrevs
     maxchainlen = max(chainlengths)
+    maxchainspan = max(chainspans)
     compratio = 1
     if totalsize:
         compratio = totalrawsize / totalsize
@@ -1867,6 +1876,7 @@ def debugrevlog(ui, repo, file_=None, **
     fmt = dfmtstr(max(avgchainlen, compratio))
     ui.write(('avg chain length  : ') + fmt % avgchainlen)
     ui.write(('max chain length  : ') + fmt % maxchainlen)
+    ui.write(('max chain reach  : ') + fmt % maxchainspan)
     ui.write(('compression ratio : ') + fmt % compratio)
 
     if format > 0:
diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -29,6 +29,7 @@
   
   avg chain length  : 0
   max chain length  : 0
+  max chain reach  : 44
   compression ratio : 0
   
   uncompressed data size (min/max/avg) : 43 / 43 / 43


More information about the Mercurial-devel mailing list