stablesort: introduce a small debugstablesortcache command
This give a small insight on the cache content.
--- a/hgext3rd/evolve/stablesort.py Sun Sep 08 11:56:11 2019 +0200
+++ b/hgext3rd/evolve/stablesort.py Sun Sep 08 13:31:28 2019 +0200
@@ -156,6 +156,46 @@
displayer.flush(ctx)
displayer.close()
+@eh.command(
+ b'debugstablesortcache',
+ [] + commands.formatteropts,
+ _(b''))
+def debugstablesortcache(ui, repo, **opts):
+ """display data about the stable sort cache of a repository
+ """
+ unfi = repo.unfiltered()
+ revs = unfi.revs('all()')
+ nbrevs = len(revs)
+ ui.write('number of revisions: %12d\n' % nbrevs)
+ merge = unfi.revs('merge()')
+ nbmerge = len(merge)
+ cache = unfi.stablesort
+ ui.write('number of merge: %12d\n' % nbmerge)
+ alljumps = []
+ alljumpssize = []
+ for r in merge:
+ jumps = cache.getjumps(unfi, r)
+ if jumps is None:
+ continue # not a merge
+ jumps = list(jumps)
+ alljumps.append(jumps)
+ alljumpssize.append(len(jumps))
+ nbjumps = sum(alljumpssize)
+ ui.write('number of jumps: %12d\n' % nbjumps)
+ if not nbjumps:
+ return 0
+ avgjumps = nbjumps / float(len(alljumpssize))
+ ui.write('average jumps: %6.3f\n' % avgjumps)
+ alljumpssize.sort()
+ medianjumps = alljumpssize[len(alljumpssize) // 2]
+ ui.write('median jumps: %12d\n' % medianjumps)
+ tensjumps = alljumpssize[len(alljumpssize) * 9 // 10]
+ ui.write('90%% jumps: %12d\n' % tensjumps)
+ centsjumps = alljumpssize[len(alljumpssize) * 99 // 100]
+ ui.write('99%% jumps: %12d\n' % centsjumps)
+ ui.write('max jumps: %12d\n' % max(alljumpssize))
+ ui.write('jump cache size: %12d bytes\n' % (nbjumps * 12))
+
def stablesort_branchpoint(repo, revs, mergecallback=None):
"""return '::revs' topologically sorted in "stable" order