##// END OF EJS Templates
debugdeltachain: output information about sparse read if enabled
Paul Morelle -
r35050:5cbbef8d default
parent child Browse files
Show More
@@ -587,11 +587,22 b' def debugdeltachain(ui, repo, file_=None'
587 587 the delta chain for this revision
588 588 :``extraratio``: extradist divided by chainsize; another representation of
589 589 how much unrelated data is needed to load this delta chain
590
591 If the repository is configured to use the sparse read, additional keywords
592 are available:
593
594 :``readsize``: total size of data read from the disk for a revision
595 (sum of the sizes of all the blocks)
596 :``largestblock``: size of the largest block of data read from the disk
597 :``readdensity``: density of useful bytes in the data read from the disk
598
599 The sparse read can be enabled with experimental.sparse-read = True
590 600 """
591 601 opts = pycompat.byteskwargs(opts)
592 602 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
593 603 index = r.index
594 604 generaldelta = r.version & revlog.FLAG_GENERALDELTA
605 withsparseread = getattr(r, '_withsparseread', False)
595 606
596 607 def revinfo(rev):
597 608 e = index[rev]
@@ -627,15 +638,20 b' def debugdeltachain(ui, repo, file_=None'
627 638
628 639 fm.plain(' rev chain# chainlen prev delta '
629 640 'size rawsize chainsize ratio lindist extradist '
630 'extraratio\n')
641 'extraratio')
642 if withsparseread:
643 fm.plain(' readsize largestblk rddensity')
644 fm.plain('\n')
631 645
632 646 chainbases = {}
633 647 for rev in r:
634 648 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
635 649 chainbase = chain[0]
636 650 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
637 basestart = r.start(chainbase)
638 revstart = r.start(rev)
651 start = r.start
652 length = r.length
653 basestart = start(chainbase)
654 revstart = start(rev)
639 655 lineardist = revstart + comp - basestart
640 656 extradist = lineardist - chainsize
641 657 try:
@@ -650,7 +666,7 b' def debugdeltachain(ui, repo, file_=None'
650 666 fm.write('rev chainid chainlen prevrev deltatype compsize '
651 667 'uncompsize chainsize chainratio lindist extradist '
652 668 'extraratio',
653 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n',
669 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f',
654 670 rev, chainid, len(chain), prevrev, deltatype, comp,
655 671 uncomp, chainsize, chainratio, lineardist, extradist,
656 672 extraratio,
@@ -659,6 +675,26 b' def debugdeltachain(ui, repo, file_=None'
659 675 uncompsize=uncomp, chainsize=chainsize,
660 676 chainratio=chainratio, lindist=lineardist,
661 677 extradist=extradist, extraratio=extraratio)
678 if withsparseread:
679 readsize = 0
680 largestblock = 0
681 for revschunk in revlog._slicechunk(r, chain):
682 blkend = start(revschunk[-1]) + length(revschunk[-1])
683 blksize = blkend - start(revschunk[0])
684
685 readsize += blksize
686 if largestblock < blksize:
687 largestblock = blksize
688
689 readdensity = float(chainsize) / float(readsize)
690
691 fm.write('readsize largestblock readdensity',
692 ' %10d %10d %9.5f',
693 readsize, largestblock, readdensity,
694 readsize=readsize, largestblock=largestblock,
695 readdensity=readdensity)
696
697 fm.plain('\n')
662 698
663 699 fm.end()
664 700
@@ -77,6 +77,40 b' debugdelta chain basic output'
77 77 }
78 78 ]
79 79
80 debugdelta chain with sparse read enabled
81
82 $ cat >> $HGRCPATH <<EOF
83 > [experimental]
84 > sparse-read = True
85 > EOF
86 $ hg debugdeltachain -m
87 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity
88 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000
89
90 $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen} {readsize} {largestblock} {readdensity}\n'
91 0 1 1 44 44 1.0
92
93 $ hg debugdeltachain -m -Tjson
94 [
95 {
96 "chainid": 1,
97 "chainlen": 1,
98 "chainratio": 1.02325581395,
99 "chainsize": 44,
100 "compsize": 44,
101 "deltatype": "base",
102 "extradist": 0,
103 "extraratio": 0.0,
104 "largestblock": 44,
105 "lindist": 44,
106 "prevrev": -1,
107 "readdensity": 1.0,
108 "readsize": 44,
109 "rev": 0,
110 "uncompsize": 43
111 }
112 ]
113
80 114 Test max chain len
81 115 $ cat >> $HGRCPATH << EOF
82 116 > [format]
General Comments 0
You need to be logged in to leave comments. Login now