Mercurial > hg
view tests/test-push-validation.t @ 29787:80df04266a16
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.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 14 Aug 2016 18:37:24 -0700 |
parents | 2a03a365f645 |
children |
line wrap: on
line source
$ hg init test $ cd test $ cat > .hg/hgrc <<EOF > [server] > validate=1 > EOF $ echo alpha > alpha $ echo beta > beta $ hg addr adding alpha adding beta $ hg ci -m 1 $ cd .. $ hg clone test test-clone updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved Test spurious filelog entries: $ cd test-clone $ echo blah >> beta $ cp .hg/store/data/beta.i tmp1 $ hg ci -m 2 $ cp .hg/store/data/beta.i tmp2 $ hg -q rollback $ mv tmp2 .hg/store/data/beta.i $ echo blah >> beta $ hg ci -m '2 (corrupt)' Expected to fail: $ hg verify checking changesets checking manifests crosschecking files in changesets and manifests checking files beta@1: dddc47b3ba30 not in manifests 2 files, 2 changesets, 4 total revisions 1 integrity errors encountered! (first damaged changeset appears to be 1) [1] $ hg push pushing to $TESTTMP/test (glob) searching for changes adding changesets adding manifests adding file changes transaction abort! rollback completed abort: received spurious file revlog entry [255] $ hg -q rollback $ mv tmp1 .hg/store/data/beta.i $ echo beta > beta Test missing filelog entries: $ cp .hg/store/data/beta.i tmp $ echo blah >> beta $ hg ci -m '2 (corrupt)' $ mv tmp .hg/store/data/beta.i Expected to fail: $ hg verify checking changesets checking manifests crosschecking files in changesets and manifests checking files beta@1: manifest refers to unknown revision dddc47b3ba30 2 files, 2 changesets, 2 total revisions 1 integrity errors encountered! (first damaged changeset appears to be 1) [1] $ hg push pushing to $TESTTMP/test (glob) searching for changes adding changesets adding manifests adding file changes transaction abort! rollback completed abort: missing file data for beta:dddc47b3ba30e54484720ce0f4f768a0f4b6efb9 - run hg verify [255] $ cd ..