Patchwork [V2] debugdeltachain: display how many chunks would be read in sparse-read mode

login
register
mail settings
Submitter Paul Morelle
Date Jan. 17, 2018, 1:30 p.m.
Message ID <77d4c2b07d6be9219a12.1516195827@taranis.localdomain>
Download mbox | patch
Permalink /patch/26815/
State Accepted
Headers show

Comments

Paul Morelle - Jan. 17, 2018, 1:30 p.m.
# HG changeset patch
# User Paul Morelle <paul.morelle@octobus.net>
# Date 1508157126 -7200
#      Mon Oct 16 14:32:06 2017 +0200
# Node ID 77d4c2b07d6be9219a127fc00b333dca9f65b45f
# Parent  821d8a5ab4ff890a7732c2e4cdcc7f32191e5942
# EXP-Topic debug-sparse-read
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 77d4c2b07d6b
debugdeltachain: display how many chunks would be read in sparse-read mode
Augie Fackler - Jan. 17, 2018, 10:24 p.m.
> On Jan 17, 2018, at 08:30, Paul Morelle <paul.morelle@octobus.net> wrote:
> 
> # HG changeset patch
> # User Paul Morelle <paul.morelle@octobus.net>
> # Date 1508157126 -7200
> #      Mon Oct 16 14:32:06 2017 +0200
> # Node ID 77d4c2b07d6be9219a127fc00b333dca9f65b45f
> # Parent  821d8a5ab4ff890a7732c2e4cdcc7f32191e5942
> # EXP-Topic debug-sparse-read
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 77d4c2b07d6b
> debugdeltachain: display how many chunks would be read in sparse-read mode

queued, thanks
Yuya Nishihara - Jan. 18, 2018, 12:21 p.m.
On Wed, 17 Jan 2018 14:30:27 +0100, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle <paul.morelle@octobus.net>
> # Date 1508157126 -7200
> #      Mon Oct 16 14:32:06 2017 +0200
> # Node ID 77d4c2b07d6be9219a127fc00b333dca9f65b45f
> # Parent  821d8a5ab4ff890a7732c2e4cdcc7f32191e5942
> # EXP-Topic debug-sparse-read
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 77d4c2b07d6b
> debugdeltachain: display how many chunks would be read in sparse-read mode

>              readdensity = float(chainsize) / float(readsize)
>  
> -            fm.write('readsize largestblock readdensity',
> -                     ' %10d %10d %9.5f',
> -                     readsize, largestblock, readdensity,
> +            if util.safehasattr(revlog, '_slicechunk'):
> +                revchunks = tuple(revlog._slicechunk(r, chain))
> +            else:
> +                revchunks = (chain,)

Nit: hasattr() isn't necessary. revlog._slicechunk() is used in the previous
block.

Patch

diff -r 821d8a5ab4ff -r 77d4c2b07d6b mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Tue Jan 16 22:14:33 2018 +0900
+++ b/mercurial/debugcommands.py	Mon Oct 16 14:32:06 2017 +0200
@@ -600,6 +600,7 @@ 
                        (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
+    :``srchunks``:  in how many data hunks the whole revision would be read
 
     The sparse read can be enabled with experimental.sparse-read = True
     """
@@ -645,7 +646,7 @@ 
              'size    rawsize  chainsize     ratio   lindist extradist '
              'extraratio')
     if withsparseread:
-        fm.plain('   readsize largestblk rddensity')
+        fm.plain('   readsize largestblk rddensity srchunks')
     fm.plain('\n')
 
     chainbases = {}
@@ -693,11 +694,17 @@ 
 
             readdensity = float(chainsize) / float(readsize)
 
-            fm.write('readsize largestblock readdensity',
-                     ' %10d %10d %9.5f',
-                     readsize, largestblock, readdensity,
+            if util.safehasattr(revlog, '_slicechunk'):
+                revchunks = tuple(revlog._slicechunk(r, chain))
+            else:
+                revchunks = (chain,)
+            srchunks = len(revchunks)
+
+            fm.write('readsize largestblock readdensity srchunks',
+                     ' %10d %10d %9.5f %8d',
+                     readsize, largestblock, readdensity, srchunks,
                      readsize=readsize, largestblock=largestblock,
-                     readdensity=readdensity)
+                     readdensity=readdensity, srchunks=srchunks)
 
         fm.plain('\n')
 
diff -r 821d8a5ab4ff -r 77d4c2b07d6b tests/test-debugcommands.t
--- a/tests/test-debugcommands.t	Tue Jan 16 22:14:33 2018 +0900
+++ b/tests/test-debugcommands.t	Mon Oct 16 14:32:06 2017 +0200
@@ -86,8 +86,8 @@ 
   > sparse-read = True
   > EOF
   $ hg debugdeltachain -m
-      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio   readsize largestblk rddensity
-        0       1        1       -1    base         44         43         44   1.02326        44         0    0.00000         44         44   1.00000
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio   readsize largestblk rddensity srchunks
+        0       1        1       -1    base         44         43         44   1.02326        44         0    0.00000         44         44   1.00000        1
 
   $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen} {readsize} {largestblock} {readdensity}\n'
   0 1 1 44 44 1.0
@@ -109,10 +109,42 @@ 
     "readdensity": 1.0,
     "readsize": 44,
     "rev": 0,
+    "srchunks": 1,
     "uncompsize": 43
    }
   ]
 
+  $ printf "This test checks things.\n" >> a
+  $ hg ci -m a
+  $ hg branch other
+  marked working directory as branch other
+  (branches are permanent and global, did you want a bookmark?)
+  $ for i in `$TESTDIR/seq.py 5`; do
+  >   printf "shorter ${i}" >> a
+  >   hg ci -m "a other:$i"
+  >   hg up -q default
+  >   printf "for the branch default we want longer chains: ${i}" >> a
+  >   hg ci -m "a default:$i"
+  >   hg up -q other
+  > done
+  $ hg debugdeltachain a -T '{rev} {srchunks}\n' \
+  >    --config experimental.sparse-read.density-threshold=0.50 \
+  >    --config experimental.sparse-read.min-gap-size=0
+  0 1
+  1 1
+  2 1
+  3 1
+  4 1
+  5 1
+  6 1
+  7 1
+  8 1
+  9 1
+  10 2
+  11 1
+  $ hg --config extensions.strip= strip --no-backup -r 1
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
 Test max chain len
   $ cat >> $HGRCPATH << EOF
   > [format]