Open main menu

Manual:Profiling/Xhprof

< Manual:Profiling(Redirected from Xhprof)

Starting with MediaWiki 1.25, you can use XHProf to profile code. You can install the pecl package or see if your distribution has a package for XHProf. HHVM has XHProf built in.

InstallingEdit

HHVM has XHProf built-in. For PHP5 (Zend) users:

  • Use the php5-xhprof package provided by your system's package manager
  • Alternatively, download the source from pecl and build manually:
wget https://pecl.php.net/get/xhprof-0.9.4.tgz
tar xfvz xhprof-0.9.4.tgz
cd xhprof-0.9.4/
cd extension/
phpize
./configure
make
sudo make install

After installing XHProf, be sure it's included in php.ini. It should be in a like looking like this:

extension=xhprof.so

Remember to restart apache after modifying php.ini.

On PHP 5.5-5.6 there's a bug in xhprof that may cause apache to crash. The patch provided on the bug fixed the issue for me. Currently it does not support PHP 7, which is why xhprof is being replaced with Excimer.

ConfigurationEdit

An example StartProfiler.php file:

$wgProfiler['class'] = 'ProfilerXhprof';
$wgProfiler['output'] = array( 'text' );

When enabled, ProfilerXhprof unconditionally calls xhprof_enable(), and will cause a fatal error if xhprof is not installed.


In addition to the normal $wgProfiler options, ProfilerXhprof supports these settings:

$wgProfiler['flags']
Flags to pass to xhprof_enable() (e.g. XHPROF_FLAGS_NO_BUILTINS, XHPROF_FLAGS_CPU, XHPROF_FLAGS_MEMORY). See the XHProf documentation for more details.
$wgProfiler['exclude']
Array of function names to exclude from the profiler data collection and reports.
Note: HHVM's implementation of xhprof does not currently respect this setting [1].
$wgProfiler['include']
Array of function names to include in profiling.
The data collected by XHProf is filtered to show only edges involving the given functions when generating reports.

See alsoEdit