comparison mercurial/debugcommands.py @ 35059:5cbbef8d2a57

debugdeltachain: output information about sparse read if enabled
author Paul Morelle <paul.morelle@octobus.net>
date Thu, 26 Oct 2017 09:27:09 +0200
parents 762ea8a1f5e7
children 8f6641fa7c89
comparison
equal deleted inserted replaced
35058:a68c3420be41 35059:5cbbef8d2a57
585 base of delta chain to end of this revision; a measurement 585 base of delta chain to end of this revision; a measurement
586 of how much extra data we need to read/seek across to read 586 of how much extra data we need to read/seek across to read
587 the delta chain for this revision 587 the delta chain for this revision
588 :``extraratio``: extradist divided by chainsize; another representation of 588 :``extraratio``: extradist divided by chainsize; another representation of
589 how much unrelated data is needed to load this delta chain 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 opts = pycompat.byteskwargs(opts) 601 opts = pycompat.byteskwargs(opts)
592 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) 602 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
593 index = r.index 603 index = r.index
594 generaldelta = r.version & revlog.FLAG_GENERALDELTA 604 generaldelta = r.version & revlog.FLAG_GENERALDELTA
605 withsparseread = getattr(r, '_withsparseread', False)
595 606
596 def revinfo(rev): 607 def revinfo(rev):
597 e = index[rev] 608 e = index[rev]
598 compsize = e[1] 609 compsize = e[1]
599 uncompsize = e[2] 610 uncompsize = e[2]
625 636
626 fm = ui.formatter('debugdeltachain', opts) 637 fm = ui.formatter('debugdeltachain', opts)
627 638
628 fm.plain(' rev chain# chainlen prev delta ' 639 fm.plain(' rev chain# chainlen prev delta '
629 'size rawsize chainsize ratio lindist extradist ' 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 chainbases = {} 646 chainbases = {}
633 for rev in r: 647 for rev in r:
634 comp, uncomp, deltatype, chain, chainsize = revinfo(rev) 648 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
635 chainbase = chain[0] 649 chainbase = chain[0]
636 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) 650 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
637 basestart = r.start(chainbase) 651 start = r.start
638 revstart = r.start(rev) 652 length = r.length
653 basestart = start(chainbase)
654 revstart = start(rev)
639 lineardist = revstart + comp - basestart 655 lineardist = revstart + comp - basestart
640 extradist = lineardist - chainsize 656 extradist = lineardist - chainsize
641 try: 657 try:
642 prevrev = chain[-2] 658 prevrev = chain[-2]
643 except IndexError: 659 except IndexError:
648 664
649 fm.startitem() 665 fm.startitem()
650 fm.write('rev chainid chainlen prevrev deltatype compsize ' 666 fm.write('rev chainid chainlen prevrev deltatype compsize '
651 'uncompsize chainsize chainratio lindist extradist ' 667 'uncompsize chainsize chainratio lindist extradist '
652 'extraratio', 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 rev, chainid, len(chain), prevrev, deltatype, comp, 670 rev, chainid, len(chain), prevrev, deltatype, comp,
655 uncomp, chainsize, chainratio, lineardist, extradist, 671 uncomp, chainsize, chainratio, lineardist, extradist,
656 extraratio, 672 extraratio,
657 rev=rev, chainid=chainid, chainlen=len(chain), 673 rev=rev, chainid=chainid, chainlen=len(chain),
658 prevrev=prevrev, deltatype=deltatype, compsize=comp, 674 prevrev=prevrev, deltatype=deltatype, compsize=comp,
659 uncompsize=uncomp, chainsize=chainsize, 675 uncompsize=uncomp, chainsize=chainsize,
660 chainratio=chainratio, lindist=lineardist, 676 chainratio=chainratio, lindist=lineardist,
661 extradist=extradist, extraratio=extraratio) 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 fm.end() 699 fm.end()
664 700
665 @command('debugdirstate|debugstate', 701 @command('debugdirstate|debugstate',
666 [('', 'nodates', None, _('do not display the saved mtime')), 702 [('', 'nodates', None, _('do not display the saved mtime')),