Hello,
Yesterday I have been made aware of a built-in profiling tool in MediaWiki. I played a bit with it and wondered if I could implement such a tool for another project.
This afternoon I finally found a good way of profiling mediawiki cpu usage, a picture of the result is at: http://www.twenkill.net/phpprofiler.png (might be unavailable depending of my home connection status).
Using debian GNU/Linux, following is a little howto to get the same window opening on your screen.
1/ PROFILER
Install the profiling tool: apt-get install php4-apd To enable profiling in mediawiki edit your index.php file and insert at top: apd_set_pprof_trace();
Now each time a web request is made on your website, a file pprof.<apachepid> will be generated in /var/log/php4-apd/
This is a serious performance eater and should only be enable when you need profiling outputs !
2/ GUI FRONTEND
The gui frontend I use is Kcachegrind: apt-get install kcachegrind . As far as I understand, it uses Caltree profiling tool and Valgrind to make a graphical representation of a C software.
KCacheGrind isn't able to read pprof file format so you will have to convert it. A script is available at: http://cvs.php.net/co.php/pecl/apd/pprof2calltree?r=1.3 Eventually edit it so it looks like /usr/bin/pprof.
Then convert the pprof file: $ pprof2calltree -f pprof.29539 Writing kcachegrind compatible output to cachegrind.out.pprof.29539 $ ls cachegrind.out.pprof.29539 pprof.29539 $
If pprof2calltree start outputing lot of lines, you need to raise the memory usage limit in your cgi php.ini file ( /etc/php4/cgi/php.ini ).
Now launch kcachegrind: $ kcachegrind cachegrind.out.pprof.29539
Note: You will need the graphwiz library to generate the call maps: apt-get install graphwiz.
Enjoy ! :o)
Wow! That's _great_ information.
I wonder if it would justify removing the wfProfileX() functions from MediaWiki. They really, really clutter up the code, and according to Ashar's graph, they take up almost 4% of the runtime!
Also, could you generate some conclusions from the profiling info?
~ESP
Evan Prodromou wrote:
Wow! That's _great_ information.
I wonder if it would justify removing the wfProfileX() functions from MediaWiki. They really, really clutter up the code, and according to Ashar's graph, they take up almost 4% of the runtime!
Hello,
I am not sure it takes that much cpu time, the profiling shown in the screenshot comes from my dev wiki using a very simple page.
Also, could you generate some conclusions from the profiling info?
I am actually trying to track memory usage to lower it. My wiki need php memory_limit to be set at 10MB for ex, which seems too much. My low target is to save about 1.5MB, high target is 3.2MB.
Also, it looks like the language->ucfirst() method use a LOT of cpu time and could be improved.
wikitech-l@lists.wikimedia.org