Wez Furlong wrote a PECL extension to provide a DTrace probe within PHP more than 4 years back. As part of Web Stack project within OpenSolaris, this extension has been made available within Solaris 10 as well as in OpenSolaris distribution in the last year or so. 

Now, with the upcoming release of OpenSolaris 2009.06 (more specifically with Indiana build 110 or above), PHP runtime has been updated to the latest 5.2.9 release. See my earlier blog on this topic. Besides PHP version update, David Soria Parra - contributor within open source projects like Mercurial, PHP Web Stack has made  this (experimental) patch available to provide the following additional DTrace probes within PHP for this release :

* compile-file-entry / compile-file-return -> This proble wil fire whenever Zend engine need to compile a given PHP script and can provide information as to which PHP script is currently going through PHP compilation process along with start and end line number. Note: PHP engine within OpenSolaris includes APC PECL extension - which caches the compiled PHP script when requested again and hence this probe will not fire in that circumstance.

* function-entry / function-return -> This probe will fire whenever Zend engine is executing a PHP function and can provide information as to which PHP function along with its file name and line number is currently being executed by PHP Zend engine.

* execute-entry / execute-return -> This probe will fire while executing PHP script and can provide information as to which file, line number is currently being executed by PHP Zend engine.

* exception-thrown / exception-catched -> This probe gets fired whenever PHP runtime encounters an exception and can the classname when an exception is thrown.

* error -> This probe gets fired whenever PHP runtime throws an error and can provide information like the error message, file name in which the error happened and the corresponding line number.

* request-startup / request-shutdown  -> This probe gets fired at the start and end of processing a given PHP script and can provide the filename of the script , request URI . This should allow a given DTrace script to track the start and end of PHP script. 

Note:  this patch is under active development and will be further refined to add additional DTrace probes as well as to address any user reported issues. 

Considering that DTrace support is available for Mac as well as FreeBSD, I am sure, PHP community will be interested into looking into this patch as well.

Okay, so now, if you are interested in trying out OpenSolaris 2009.06 (preview build) and the updated AMP stack, check out my earlier  blog for detailed steps on this.

Here is a sample DTrace script that you can use as a reference point.

Comments:

Dude, I know OpenSolaris is a solid product. But with Sun's future uncertain, I have lost whatever little enthusiasm I had for it. Your management team has failed you. Accept it and move on. The RIF's are coming.

Posted by James Sidis on April 06, 2009 at 04:01 AM PDT #

Hey! Has webstack already mcrypt extension, or do I need to install it manually. Thx.

Posted by Damian on April 06, 2009 at 05:23 AM PDT #

nice blog about dtrace and php!

James Sidis: OpenSolaris is open source. Thanks to that property the OS is now much greater than Sun Microsystems and it will survive what ever future Sun Microsystems will meet. There is no reason not to care about OpenSolaris because Sun might be in trouble (which it really isn't actually).

Posted by Kristofer on April 06, 2009 at 09:33 AM PDT #

Yes, Web Stack 1.5 release - integrated within OpenSolaris 2009.06 has MCrypt extension .

Posted by Sriram Natarajan on April 06, 2009 at 09:45 AM PDT #

- you will need to download the sample script from the above blog and then chmod 755 before running dtrace profiles for PHP
- finally to run this script, u will need to do
a)open a command line terminal
b) run the following command
pfexec ./<script-name>

Posted by Sriram Natarajan on April 08, 2009 at 08:08 PM PDT #

which is better APC Cache or MEMCache?

Posted by awake on April 18, 2009 at 05:33 PM PDT #

apc - cached your compiled php script. memcache - allows php to work with memcached server - for caching the data that would otherwise be needed to be obtained from a database. APC as well as memcached work as complement to each other and large sites deploy them both .. php caches the compiled php script by default (uses APC). now, to use memcache - programmers will need to explicitly program their applications to use them.

Posted by Sriram Natarajan on April 19, 2009 at 08:39 AM PDT #

Post a Comment:
Comments are closed for this entry.

This blog copyright 2009 by natarajan