Saturday, May 1, 2010

Xdebug Trigger Mode: XDEBUG_PROFILE is Not Working

One of the two ways to configure profiling in Xdebug is through "trigger mode". There are at least two reasons why you wanna do it. One, you need just select which PHP pages you need profiled and two, you cannot actively enable profiling due to whatever performance issues (Xdebug or other profiler are well known to cause performance issues) your machine might have. "Xdebug Trigger Mode" works by first turning on xdebug.profiler_enable_trigger = on and then appending XDEBUG_PROFILE=1 in the URL query string the make the request. This should generate an appropriate cachegrind file

Xdebug Trigger Mode on the other hand have a few well-known issues or should I say, common configuration errors. Let's take a look at some of those that are frequently encountered.



1. Xdebug is not configured as a zend extension i.e

Cause: "extension=xdebug.so" is the configuration entry placed on php.ini.
Fix: Change the configuration to zend_extension = xdebug.so

2. Trying to save the cachegrind file to a custom directory.

Cause: Apache and xdebug doesn't have permission to access the custom directory as specified in the xdebug.profiler_output_dir =/path/to/dir
Fix: Change mode and ownership to the directory.

Example for *nix systems:
# chown apache.apache /path/to/dir
# chmod +w /path/to/dir


3. Output filename is in the wrong format.

Cause: xdebug.profiler_output_name is wrongly formatted i.e xdebug.profiler_output_name = %P (instead of lowercase %p).
Fix: Make sure that you follow that you just use the xdebug output name specifiers when formatting the output name.

4. You could have gone of profiling without restarting your web server after making some changes to configuration.

Cause: Web server doesn't have the configuration changes loaded.
Fix: Load the configuration changes by restarting the web server.

Example for *nix systems:
# /etc/init.d/httpd restart
  • Related Links Widget for Blogspot

No comments: