Patchwork debugrevlog: also display the largest delta chain span

login
register
mail settings
Submitter Pierre-Yves David
Date June 25, 2017, 12:43 p.m.
Message ID <97720b4842c41e21c943.1498394603@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21698/
State Accepted
Headers show

Comments

Pierre-Yves David - June 25, 2017, 12:43 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Yuya Nishihara - June 26, 2017, 12:44 p.m.
On Sun, 25 Jun 2017 14:43:23 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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

Queued, thanks.

Patch

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