Commit Graph

18 Commits

Author SHA1 Message Date
Martin von Zweigbergk
255c4290a2 tests: make test-profile.t pass if statprof didn't collect samples
We had the first 3 tests in test-profile.t fail because the output
didn't match. I have not yet confirmed that this was because no
samples were collected, but we shouldn't require samples to be
collected for the test to pass either way.

Differential Revision: https://phab.mercurial-scm.org/D199
2017-07-31 12:43:26 -07:00
Pulkit Goyal
b4347ea80f py3: make sure commands name are bytes in tests 2017-06-25 08:20:05 +05:30
Pierre-Yves David
81c8d3b7b6 profile: support --profile in alias and abbreviated version (--prof)
We now process the "--profile" a second time after alias has been processed and
the command argument fully parsed. If appropriate we enable profiling at that
time.

In these situation, the --profile will cover less than if the full --profile
flag was passed on the command line. This is better than the previous behavior
(flag ignored) and still fullfil multiple valid usecases.
2017-06-09 12:36:07 +01:00
Jun Wu
610c5f87a9 profiling: allow loading profiling extension before everything else
459366b580cf makes profiler start early without loading extensions. That
makes it impossible for an extension to add customized profilers.

This patch adds a special case: if a profiler is not found but an extension
with the same name could be loaded, load that extension first, and expect it
to have a "profile" contextmanager method. This allows customized profilers
and extension setup time is still profiled.
2017-05-22 01:17:49 -07:00
Yuya Nishihara
3e663dde68 registrar: move cmdutil.command to registrar module (API)
cmdutil.command wasn't a member of the registrar framework only for a
historical reason. Let's make that happen. This patch keeps cmdutil.command
as an alias for extension compatibility.
2016-01-09 23:07:20 +09:00
Yuya Nishihara
5f9b0dd4d2 test-profile: allow negative time in JSON output (issue5542)
I don't know why it can be a negative number, but that shouldn't be important
here.
2017-04-20 22:45:45 +09:00
Gregory Szorc
9c03a7696d statprof: require input file
statprof has a __main__ handler that allows viewing of previously
written data files. As Yuya pointed out during review, 82ee01726a77
broke this. This patch fixes that.
2017-01-18 22:45:07 -08:00
Gregory Szorc
d1e86f5ae3 profiling: make statprof the default profiler (BC)
The statprof sampling profiler runs with significantly less overhead.
Its data is therefore more useful. Furthermore, its default output
shows the hotpath by default, which I've found to be way more useful
than the default profiler's function time table.

There is one behavioral regression with this change worth noting:
the statprof profiler currently doesn't profile individual hgweb
requests like lsprof does. This is because the current implementation
of statprof only profiles the thread that started profiling.

The ability for lsprof to profile individual hgweb requests is
relatively new and likely not widely used. Furthermore, I have plans
to modify statprof to support profiling multiple threads. I expect
that change to go through several iterations. I'm submitting this
patch first so there is more time to test statprof. Perfect is the
enemy of good.
2016-11-04 21:44:25 -07:00
Gregory Szorc
c60af834ba profiling: use vendored statprof and upstream enhancements (BC)
Now that the statprof module is vendored and suitable for use, we
switch our statprof profiler to use it. This required some minor
changes because of drift between the official statprof profiler
and the vendored copy.

We also incorporate Facebook's improvements from the "statprofext"
extension at
https://bitbucket.org/facebook/hg-experimental, notably support for
different display formats.

Because statprof output is different, this is marked as BC. Although
most users likely won't notice since most users don't profile.
2016-11-04 20:50:38 -07:00
Gregory Szorc
504fb2c9d4 tests: explicitly use ls profiler
In preparation for making the statprof profiler the default.
2016-08-17 08:52:15 -07:00
Gregory Szorc
4cfd8623b8 hgweb: profile HTTP requests
Currently, running `hg serve --profile` doesn't yield anything useful:
when the process is terminated the profiling output displays results
from the main thread, which typically spends most of its time in
select.select(). Furthermore, it has no meaningful results from
mercurial.* modules because the threads serving HTTP requests don't
actually get profiled.

This patch teaches the hgweb wsgi applications to profile individual
requests. If profiling is enabled, the profiler kicks in after
HTTP/WSGI environment processing but before Mercurial's main request
processing.

The profile results are printed to the configured profiling output.
If running `hg serve` from a shell, they will be printed to stderr,
just before the HTTP request line is logged. If profiling to a file,
we only write a single profile to the file because the file is not
opened in append mode. We could add support for appending to files
in a future patch if someone wants it.

Per request profiling doesn't work with the statprof profiler because
internally that profiler collects samples from the thread that
*initially* requested profiling be enabled. I have plans to address
this by vendoring Facebook's customized statprof and then improving
it.
2016-08-14 18:37:24 -07:00
Durham Goode
74879ebad9 profiling: allow logging profile to the blackbox
This allows specifying '--config profiling.output=blackbox' which will log the
profile output to the blackbox (if enabled). This is useful for doing profiling
on the server since it allows us to record the command, it's result, any
exceptions, and it's profile, all in one spot.  And we get log rotation for
free.
2015-09-08 11:39:52 -07:00
Durham Goode
47346e366e tests: fix test-profile to not depend on HGPROF environment variable
The test-profile test would fail if the user had HGPROF set to another
profiler in their environment.  This fix makes the test independent of
that environment variable.

Reverts the previous attempt to fix this, which was not cross platoform.
2013-03-12 10:37:48 -07:00
Durham Goode
11845dddc1 tests: fix test-profile to not depend on HGPROF environment variable
The test-profile test would fail if the user had HGPROF set to another
profiler in their environment.  This fix makes the test independent of
that environment variable.
2013-03-12 10:37:48 -07:00
Martin Geisler
65ea7aa7d4 dispatch: lowercase --time message 2012-06-12 14:18:18 +02:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00
Mads Kiilerich
1df3d48d73 tests: change odd uses of 'if hghave' to #if 2012-06-10 13:01:40 +02:00
Matt Mackall
eaf44b6090 tests: unify test-profile 2010-09-26 13:44:49 -05:00