Tonight during our
OpenSolaris BOF at OSCON,
PHP core developer Wez Furlong
was busy adding a
DTrace provider to PHP. After a little bit of work (and a little bit of debugging),
we got it working -- and damn is it cool. Wez implemented it as a shared object, which may then be loaded
via an explicit
extension
directive in
php.ini. Once loaded,
two probes show up: function-entry and function-return. These probes have as their
arguments a pointer to the function name, a pointer to the file name, and a line number.
This allows one to, for example, get a count of all PHP functions being called:
# dtrace -n function-entry'{@[copyinstr(arg0)] = count()}'
Or you can aggregate on file name
and quantize by line number:
# dtrace -n function-entry'{@[copyinstr(arg1)] = lquantize(arg2, 0, 5000)}'
Or you can determine the amount of wall time taken by a given PHP function:
# dtrace -n function-entry'/copyinstr(arg0) == "myfunc"/{self->ts = timestamp}'
-n function-return'/self->ts/{@ = avg(timestamp - self->ts); self->ts = 0)}'
And because it's DTrace, this can all be done on a production box -- and without regard to the number of
PHP processes. (So if you have 200 Apache processes handling PHP, the above invocations would aggregate
across them.)
When I get back, I'll download Wez's provider and post some more comprehensive examples. In the meantime, if you're a PHP developer at OSCON, stop Wez if you see him and ask him to give you a demo -- it's the kind of thing that needs to be seen to be appreciated...
Finally, if you're interested in adding your own DTrace provider to the
application, language or system that you care about, be sure to check out
Posted by Robert Milkowski on August 04, 2005 at 08:54 AM PDT #
Posted by Wez Furlong on August 04, 2005 at 10:16 AM PDT #
Posted by Wez Furlong on August 04, 2005 at 10:38 AM PDT #
Posted by Wez Furlong on August 04, 2005 at 04:48 PM PDT #
Posted by black jack internet casino on October 23, 2005 at 06:38 PM PDT #
العاب العاب فوركس فوركس فوركس فوركس فوركس
Posted by برامج on September 11, 2006 at 06:45 AM PDT #
Posted by 56465456 on April 04, 2007 at 02:20 AM PDT #
Posted by Softps on April 18, 2007 at 08:03 PM PDT #
Posted by أيظن on April 21, 2007 at 08:02 AM PDT #
Posted by 注册香港公司 on July 16, 2007 at 09:23 PM PDT #
Posted by 注册香港公司 on July 16, 2007 at 09:25 PM PDT #
Posted by 注册香港公司 on July 16, 2007 at 09:28 PM PDT #
Posted by 注册香港公司 on July 16, 2007 at 09:30 PM PDT #
Posted by 注册香港公司 on July 16, 2007 at 09:30 PM PDT #
Posted by 注册香港公司 on July 16, 2007 at 09:31 PM PDT #