You experience very bad performance on your wiki. Some saves or edits are taking a very long time (more than 10s is long).
Sometimes your wiki is running very slow, and you have no idea why. NYTProf helps you pin down the culprit by showing you where the Perl code spends most of its time.
Perl has some really great tools, and one of them is CPAN:Devel::NYTProf
. Devel::NYTProf uses the debugger functionality of Perl to place hooks and keep track of every function which gets called, and how long it lasts.
First, you have to install CPAN:Devel::NYTProf
. It is usually packaged for your distribution, otherwise use:
- On Debian/Ubuntu, simply:
sudo apt-get install libdevel-nytprof-perl
- On FreeBSD, simply:
Once installed, you need to tell the script you want to debug that it ought to use it. To do so, change the shebang line (the first line of the script) to look like this:
After that, you have to ensure the webserver can write its output file, so ensure the
directory is owned by the webserver user. Only do this during the test; it's not very secure to have this directory writable.
You may now access the wiki and run the page which you want to debug. This should create a file called
in the bin directory. NYTProf doesn't like to overwrite this file, so to run the script again, you have to remove the file. You may save several files for further analysis.
Finally, you ask NYTProf to generate HTML or CSV output based on the information it gathered:
- For HTML:
- For CSV:
In the end, you should have a nytprof folder with your data in it. If you chose the HTML version, point your browser to the
. The output should be pretty much self-explanatory.
Find bottleneck in rendering.
Only one debug at a time. You can use the
option to add the PID to the nytprof.out file. To use this option, you have to define an environment variable which has to be passed over to your CGI. You should be able to use
SetEnv NYTPROF addpid=1:file=/tmp/foswiki-nytprof.out
If you're using mod_perl, there is just one line to add in your httpd.conf:
By default you'll get a
file for the parent process and a
file for each worker process.
In case the script is taking too long to process, and Apache kills it before you're done, you may run it from the command line (assuming you're not uploading something), using something along the lines of (from the
sudo -u www-data perl -wTd:NYTProf edit -topic Sandbox.TestTopic -username YourUsername
with the appropriate values.
- 13 Nov 2010