##// END OF EJS Templates
hgweb: profile HTTP requests...
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.

File last commit:

r26587:56b2bcea default
r29787:80df0426 default
Show More
test-custom-filters.t
66 lines | 1.5 KiB | text/troff | Tads3Lexer
/ tests / test-custom-filters.t
Nicolas Dumazet
tests: unify test-custom-filters
r12124 $ hg init
$ cat > .hg/hgrc <<EOF
> [extensions]
> prefixfilter = prefix.py
> [encode]
> *.txt = stripprefix: Copyright 2046, The Masters
> [decode]
> *.txt = insertprefix: Copyright 2046, The Masters
> EOF
$ cat > prefix.py <<EOF
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 > from mercurial import error
Nicolas Dumazet
tests: unify test-custom-filters
r12124 > def stripprefix(s, cmd, filename, **kwargs):
> header = '%s\n' % cmd
> if s[:len(header)] != header:
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 > raise error.Abort('missing header "%s" in %s' % (cmd, filename))
Nicolas Dumazet
tests: unify test-custom-filters
r12124 > return s[len(header):]
> def insertprefix(s, cmd):
> return '%s\n%s' % (cmd, s)
> def reposetup(ui, repo):
> repo.adddatafilter('stripprefix:', stripprefix)
> repo.adddatafilter('insertprefix:', insertprefix)
> EOF
$ cat > .hgignore <<EOF
> .hgignore
> prefix.py
> prefix.pyc
> EOF
$ cat > stuff.txt <<EOF
> Copyright 2046, The Masters
> Some stuff to ponder very carefully.
> EOF
$ hg add stuff.txt
$ hg ci -m stuff
Repository data:
$ hg cat stuff.txt
Some stuff to ponder very carefully.
Fresh checkout:
$ rm stuff.txt
$ hg up -C
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat stuff.txt
Copyright 2046, The Masters
Some stuff to ponder very carefully.
Nicolas Dumazet
test-custom-filter: heredoc is not required for single line operations
r12125 $ echo "Very very carefully." >> stuff.txt
Nicolas Dumazet
tests: unify test-custom-filters
r12124 $ hg stat
M stuff.txt
Nicolas Dumazet
test-custom-filter: heredoc is not required for single line operations
r12125 $ echo "Unauthorized material subject to destruction." > morestuff.txt
Nicolas Dumazet
tests: unify test-custom-filters
r12124
Problem encoding:
$ hg add morestuff.txt
$ hg ci -m morestuff
abort: missing header "Copyright 2046, The Masters" in morestuff.txt
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-custom-filters
r12124 $ hg stat
M stuff.txt
A morestuff.txt