Performance Blog

Dtrace support for PHP

Posted on: May 1, 2007

Dtrace is one of the coolest things in Solaris 10, adding great observability to applications. A Dtrace provider for PHP that adds probes to function entry and exit points has long been available. I finally got around to integrating this with the php in Cool Stack. 

Bryan Cantrill has some excellent examples of how to use dtrace to trace through your php code, down to the system libraries and kernel (if you want to go that far !) .

Instructions for installing the php dtrace extension

1. Download the shared library for the extension :

2. Install the extension :

    # bunzip2<arch>.bz2
  # cp<arch> /opt/coolstack/php5/lib/php/extensions/no-debug*/

3. Enable the dtrace extension :

  Edit your php.ini (default is in /opt/coolstack/php5/lib/php.ini) and add the line :


4. Check if the extension has been correctly loaded by executing a sample php script that takes a long time to run (you can use Bryan’s blastoff.php to do this). 

#/opt/coolstack# dtrace -l |grep php
39131   php16088                php_dtrace_execute function-entry
39132   php16088       php_dtrace_execute_internal function-entry
39133   php16088                php_dtrace_execute function-return
39134   php16088       php_dtrace_execute_internal function-return

5. You should now be able to use the dtrace provider whenever you want using dtrace scripts. The dtrace provider will work with mod_php if you’re running Apache or if you’re running php stand-alone. Here is a sample command that will show which functions are called :

# dtrace -n function-entry'{printf("called %s() in %s at line %d\n", \
copyinstr(arg0), copyinstr(arg1), arg2)}' -q

Please feel free to contribute additional dtrace scripts.




3 Responses to "Dtrace support for PHP"

i have problems with dtrace and php in os2008.11. Could you help me?
dtrace: error on enabled probe ID 57 (ID 5917: invalid address (0xfceeb38b) in predicate at DIF offset 64
/arg0 != NULL && copyinstr(arg0) == ""/
printf("%d -> %-30s\n", pid, copyinstr(arg1));
/arg0 != NULL && copyinstr(arg0) == ""/
printf("%d <- %-30s\n", pid, copyinstr(arg1));
could you help me? A. Leventhal suggested me to contact you

Please use the Web Stack forum for support. It’s at
And when you do, please state which version you’re running on what platform.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Shanti's Photo


Latest Tweets



%d bloggers like this: