[PATCH] debugdeltachain: output information about sparse read if enabled
Paul Morelle
paul.morelle at octobus.net
Wed Nov 8 20:12:57 UTC 2017
# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1509002829 -7200
# Thu Oct 26 09:27:09 2017 +0200
# Node ID 13a6c881be35e7651a12f8c3442abfade2b77c88
# Parent 602c168c0207c443ac61f7a7c727b31cfb0b86ad
# EXP-Topic debugdeltachain
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 13a6c881be35
debugdeltachain: output information about sparse read if enabled
diff -r 602c168c0207 -r 13a6c881be35 mercurial/debugcommands.py
--- a/mercurial/debugcommands.py Tue Nov 07 13:18:49 2017 -0500
+++ b/mercurial/debugcommands.py Thu Oct 26 09:27:09 2017 +0200
@@ -587,11 +587,22 @@
the delta chain for this revision
:``extraratio``: extradist divided by chainsize; another representation of
how much unrelated data is needed to load this delta chain
+
+ If the repository is configured to use the sparse read, additional keywords
+ are available:
+
+ :``readsize``: total size of data read from the disk for a revision
+ (sum of the sizes of all the blocks)
+ :``largestblock``: size of the largest block of data read from the disk
+ :``readdensity``: density of useful bytes in the data read from the disk
+
+ The sparse read can be enabled with experimental.sparse-read = True
"""
opts = pycompat.byteskwargs(opts)
r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
index = r.index
generaldelta = r.version & revlog.FLAG_GENERALDELTA
+ withsparseread = getattr(r, '_withsparseread', False)
def revinfo(rev):
e = index[rev]
@@ -625,17 +636,29 @@
fm = ui.formatter('debugdeltachain', opts)
- fm.plain(' rev chain# chainlen prev delta '
- 'size rawsize chainsize ratio lindist extradist '
- 'extraratio\n')
+ header = (' rev chain# chainlen prev delta '
+ 'size rawsize chainsize ratio lindist extradist '
+ 'extraratio')
+ fmfields = ('rev chainid chainlen prevrev deltatype compsize '
+ 'uncompsize chainsize chainratio lindist extradist '
+ 'extraratio')
+ fmformats = '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f'
+ if withsparseread:
+ header += ' readsize largestblk rddensity'
+ fmfields += ' readsize largestblock readdensity'
+ fmformats += ' %10d %10d %9.5f'
+
+ fm.plain(header + '\n')
chainbases = {}
for rev in r:
comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
chainbase = chain[0]
chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
- basestart = r.start(chainbase)
- revstart = r.start(rev)
+ start = r.start
+ length = r.length
+ basestart = start(chainbase)
+ revstart = start(rev)
lineardist = revstart + comp - basestart
extradist = lineardist - chainsize
try:
@@ -646,19 +669,33 @@
chainratio = float(chainsize) / float(uncomp)
extraratio = float(extradist) / float(chainsize)
+ fmargs = (rev, chainid, len(chain), prevrev, deltatype, comp,
+ uncomp, chainsize, chainratio, lineardist, extradist,
+ extraratio)
+ fmkwargs = dict(rev=rev, chainid=chainid, chainlen=len(chain),
+ prevrev=prevrev, deltatype=deltatype, compsize=comp,
+ uncompsize=uncomp, chainsize=chainsize,
+ chainratio=chainratio, lindist=lineardist,
+ extradist=extradist, extraratio=extraratio)
+ if withsparseread:
+ readsize = 0
+ largestblock = 0
+ for revschunk in revlog._slicechunk(r, chain):
+ blkend = start(revschunk[-1]) + length(revschunk[-1])
+ blksize = blkend - start(revschunk[0])
+
+ readsize += blksize
+ if largestblock < blksize:
+ largestblock = blksize
+
+ readdensity = float(chainsize) / float(readsize)
+
+ fmargs += (readsize, largestblock, readdensity)
+ fmkwargs.update(readsize=readsize, largestblock=largestblock,
+ readdensity=readdensity)
+
fm.startitem()
- fm.write('rev chainid chainlen prevrev deltatype compsize '
- 'uncompsize chainsize chainratio lindist extradist '
- 'extraratio',
- '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n',
- rev, chainid, len(chain), prevrev, deltatype, comp,
- uncomp, chainsize, chainratio, lineardist, extradist,
- extraratio,
- rev=rev, chainid=chainid, chainlen=len(chain),
- prevrev=prevrev, deltatype=deltatype, compsize=comp,
- uncompsize=uncomp, chainsize=chainsize,
- chainratio=chainratio, lindist=lineardist,
- extradist=extradist, extraratio=extraratio)
+ fm.write(fmfields, fmformats + '\n', *fmargs, **fmkwargs)
fm.end()
More information about the Mercurial-devel
mailing list