Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Chris Jones:
Adding DTrace Probes to PHP Extensions
Dec 07, 2012 @ 15:35:09

In a new post to his site (related to the topic of this previous post) Chris Jones shows you how to setup and use DTrace support in your PHP installation for enhanced debugging abilities.

The powerful DTrace tracing facility has some PHP-specific probes that can be enabled with --enable-dtrace. DTrace for Linux is being created by Oracle and is currently in tech preview. Currently it doesn't support userspace tracing so, in the meantime, Systemtap can be used to monitor the probes implemented in PHP. This was recently outlined in David Soria Parra's post Probing PHP with Systemtap on Linux.

His examples are using the Oracle flavor of linux, but they should work for just about any unix-based system out there. He installs the tool via a yum package and compiles the latest PHP source with the "enable-dtrace" flag. He includes a simple script to connect to an Oracle database and shows the contents of the resulting "functrace.stp". He also shows how he added more "prodbes" (the points DTrace uses to profile) into the OCI8 extension for PHP (steps and source included).

tagged: dtrace extension probe tutorial compile oci8 extension

Link:

David Parra:
Probing PHP with Systemtap on Linux
Dec 05, 2012 @ 16:41:30

David Parra has a new post to his site today about a method of using Systemtap to profile PHP as the code executes (as an alternative when DTrace may not be available.

PHP introduced DTrace support with PHP 5.3, enabling probing points in the PHP executable that can be used to simplify probing of PHP applications without having to the PHP implementation details. We enabled probes on function calls, file compilation, exceptions and errors. But this has always been limited to the operating systems that support DTrace. With the popularity of DTrace, Systemap programmers decided to add a DTrace compatibility layer that allows to use DTrace probes as Systemtap probing points as well.

Thanks to a recent commit to the PHP 5.5 branch, your PHP installation (compiled with DTrace support) can be executed with the "stap" command and searched for probe points. He includes a simple Systemtap script that counts the calls of a specific function to get you started.

tagged: probe profile systemtap dtrace compile tutorial

Link:

Experimentalworks Blog:
DTracing PHP
Dec 22, 2008 @ 21:19:10

On the Experimentalworks blog a recent post looks at using DTrace, the powerful tool to debug and trace problems in an application, with your PHP applications.

Dtrace is really powerful and trying to do an introduction to all it’s features is just not possible. Therefore I will just focus on the basics, that are needed to get our stuff working. The basic idea behind Dtrace is that the kernel and userland programs fire probes on a specific location in the kernel or the userland program.

He looks at the structure of a DTrace program as well as a list of probes that you can use to help track down the problem in your application. His "first example" traces the compile time of the app and, when run on the command line, returns the time in seconds.

tagged: dtrace tutorial example compile time structure probe

Link:


Trending Topics: