[PATCH 1 of 6] profile: upgrade the "profile" context manager to a full class

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jun 9 09:07:59 EDT 2017



On 06/09/2017 01:32 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at octobus.net>
> # Date 1496882328 -3600
> #      Thu Jun 08 01:38:48 2017 +0100
> # Node ID a3a4b52464f3dbaf533f62bca7512f42c6a6d449
> # Parent  3ef319e9505f376775c91b2ab7d89ac9ac4343e9
> # EXP-Topic profile
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r a3a4b52464f3
> profile: upgrade the "profile" context manager to a full class
>
> So far we have been able to use a simple decorator for this. However using the
> current context manager makes the scope of the profiling in dispatch
> constrainted and the time frame to decide to enable profiling quite limited
> (using "maybeprofile")
>
> This is the first step toward the ability to enable the profiling from within
> the profiling scope. eg::
>
>   with maybeprofiling(ui) as profiler:
>       ...
>       bar.foo():
>       ...
>       if options['profile']:
>           profiler.start()
>       ...
>       fooz()
>       ...
>
> My target usecase is adding support for  "--profile" to alias definitions with
> effect.  These are to be used with "profiling.output=blackbox" to gather data
> about operation that get slow from time to time (eg: pull being minutes instead
> of seconds from time to time).

While backporting this series to an older Mercurial, I found out that it 
used to works fine, but got regressed (for good reason) in 4.2. The 
regression comes a changeset that move the profiling boundaries to 
includes the extensions loading time.

   changeset:   30934:6d642ecf1a89
   user:        Bryan O'Sullivan <bryano at fb.com>
   date:        Mon Feb 13 20:47:41 2017 -0800
   summary:     dispatch: start profiling earlier

Cheers,

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list