Submitter | Boris Feld |
---|---|
Date | Aug. 17, 2018, 9:42 p.m. |
Message ID | <a6ad3166c42fc257a321.1534542134@FB-lair> |
Download | mbox | patch |
Permalink | /patch/33834/ |
State | Accepted |
Headers | show |
Comments
On Fri, Aug 17, 2018 at 2:42 PM, Boris Feld <boris.feld@octobus.net> wrote: > # HG changeset patch > # User Boris Feld <boris.feld@octobus.net> > # Date 1534521066 -7200 > # Fri Aug 17 17:51:06 2018 +0200 > # Branch stable > # Node ID a6ad3166c42fc257a3214d017d2f135dc5964536 > # Parent 7e023ce26c7f5e800c778fb4ff76c6d7726666b3 > # EXP-Topic phases-perf > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r > a6ad3166c42f > perf: add a perfphasesremote command > Queued parts 1-2 for stable. I'll try to look at part 3 in a bit. > > This command measure the time we spend analysing remote phase during push > and > pull and display some information relevant to this computation. > > The `test-contrib-perf.t` expected output has to be updated but I do need > these module for this perf command. > > diff --git a/contrib/perf.py b/contrib/perf.py > --- a/contrib/perf.py > +++ b/contrib/perf.py > @@ -791,6 +791,63 @@ def perfphases(ui, repo, **opts): > timer(d) > fm.end() > > +@command('perfphasesremote', > + [], "[DEST]") > +def perfphasesremote(ui, repo, dest=None, **opts): > + """benchmark time needed to analyse phases of the remote server""" > + from mercurial.node import ( > + bin, > + ) > + from mercurial import ( > + exchange, > + hg, > + phases, > + ) > + timer, fm = gettimer(ui, opts) > + > + path = ui.paths.getpath(dest, default=('default-push', 'default')) > + if not path: > + raise error.abort(('default repository not configured!'), > + hint=("see 'hg help config.paths'")) > + dest = path.pushloc or path.loc > + branches = (path.branch, opts.get('branch') or []) > + ui.status(('analysing phase of %s\n') % util.hidepassword(dest)) > + revs, checkout = hg.addbranchrevs(repo, repo, branches, > opts.get('rev')) > + other = hg.peer(repo, opts, dest) > + > + # easier to perform discovery through the operation > + op = exchange.pushoperation(repo, other) > + exchange._pushdiscoverychangeset(op) > + > + remotesubset = op.fallbackheads > + > + with other.commandexecutor() as e: > + remotephases = e.callcommand('listkeys', > + {'namespace': 'phases'}).result() > + del other > + publishing = remotephases.get('publishing', False) > + if publishing: > + ui.status(('publishing: yes\n')) > + else: > + ui.status(('publishing: no\n')) > + > + nodemap = repo.changelog.nodemap > + nonpublishroots = 0 > + for nhex, phase in remotephases.iteritems(): > + if nhex == 'publishing': # ignore data related to publish option > + continue > + node = bin(nhex) > + if node in nodemap and int(phase): > + nonpublishroots += 1 > + ui.status(('number of roots: %d\n') % len(remotephases)) > + ui.status(('number of known non public roots: %d\n') % > nonpublishroots) > + def d(): > + phases.remotephasessummary(repo, > + remotesubset, > + remotephases) > + timer(d) > + fm.end() > + > @command('perfmanifest', [], 'REV') > def perfmanifest(ui, repo, rev, **opts): > """benchmark the time to read a manifest from disk and return a usable > diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t > --- a/tests/test-contrib-perf.t > +++ b/tests/test-contrib-perf.t > @@ -99,6 +99,8 @@ perfstatus > perfpathcopies > (no help text available) > perfphases benchmark phasesets computation > + perfphasesremote > + benchmark time needed to analyse phases of the remote > server > perfrawfiles (no help text available) > perfrevlogchunks > Benchmark operations on revlog chunks. > @@ -207,4 +209,7 @@ Check perf.py for historical portability > contrib/perf.py:\d+: (re) > > from mercurial import ( > import newer module separately in try clause for early Mercurial > + contrib/perf.py:\d+: (re) > + > from mercurial import ( > + import newer module separately in try clause for early Mercurial > [1] > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel >
Patch
diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -791,6 +791,63 @@ def perfphases(ui, repo, **opts): timer(d) fm.end() +@command('perfphasesremote', + [], "[DEST]") +def perfphasesremote(ui, repo, dest=None, **opts): + """benchmark time needed to analyse phases of the remote server""" + from mercurial.node import ( + bin, + ) + from mercurial import ( + exchange, + hg, + phases, + ) + timer, fm = gettimer(ui, opts) + + path = ui.paths.getpath(dest, default=('default-push', 'default')) + if not path: + raise error.abort(('default repository not configured!'), + hint=("see 'hg help config.paths'")) + dest = path.pushloc or path.loc + branches = (path.branch, opts.get('branch') or []) + ui.status(('analysing phase of %s\n') % util.hidepassword(dest)) + revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) + other = hg.peer(repo, opts, dest) + + # easier to perform discovery through the operation + op = exchange.pushoperation(repo, other) + exchange._pushdiscoverychangeset(op) + + remotesubset = op.fallbackheads + + with other.commandexecutor() as e: + remotephases = e.callcommand('listkeys', + {'namespace': 'phases'}).result() + del other + publishing = remotephases.get('publishing', False) + if publishing: + ui.status(('publishing: yes\n')) + else: + ui.status(('publishing: no\n')) + + nodemap = repo.changelog.nodemap + nonpublishroots = 0 + for nhex, phase in remotephases.iteritems(): + if nhex == 'publishing': # ignore data related to publish option + continue + node = bin(nhex) + if node in nodemap and int(phase): + nonpublishroots += 1 + ui.status(('number of roots: %d\n') % len(remotephases)) + ui.status(('number of known non public roots: %d\n') % nonpublishroots) + def d(): + phases.remotephasessummary(repo, + remotesubset, + remotephases) + timer(d) + fm.end() + @command('perfmanifest', [], 'REV') def perfmanifest(ui, repo, rev, **opts): """benchmark the time to read a manifest from disk and return a usable diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t --- a/tests/test-contrib-perf.t +++ b/tests/test-contrib-perf.t @@ -99,6 +99,8 @@ perfstatus perfpathcopies (no help text available) perfphases benchmark phasesets computation + perfphasesremote + benchmark time needed to analyse phases of the remote server perfrawfiles (no help text available) perfrevlogchunks Benchmark operations on revlog chunks. @@ -207,4 +209,7 @@ Check perf.py for historical portability contrib/perf.py:\d+: (re) > from mercurial import ( import newer module separately in try clause for early Mercurial + contrib/perf.py:\d+: (re) + > from mercurial import ( + import newer module separately in try clause for early Mercurial [1]