# HG changeset patch # User Pierre-Yves David # Date 1567942288 -7200 # Node ID 9a52930f678121d5454bcc4c7d3fabbac991c495 # Parent 72cebe6642d70efe56ee825b5c9a547992bd8733 stablesort: introduce a small debugstablesortcache command This give a small insight on the cache content. diff -r 72cebe6642d7 -r 9a52930f6781 hgext3rd/evolve/stablesort.py --- 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