This is an overview of the DTrace functionality in perl 5.10.1 and later. It's suitable for someone familiar with perl but not very familiar with DTrace.
web application's "real" code execution pathway! • Profile why NFS gets super busy at 0430 and a directory tree traversal takes 2 hours instead of 2 minutes.!
a probe, optional predicate and optional actions in a braced clause! • Supports BEGIN and END blocks! • Local variables (this->foo = 42)! • Aggregate/associative variables (prefixed with @)! • One liner support in the form! dtrace -n 'probe /predicate/ {action}'
/* Count sub entries by package and sub name * arg3 = package name (Foo::Bar) * arg0 = subroutine name (do_something) */ @[strjoin(strjoin(copyinstr(arg3),"::"),copyinstr(arg0))] = count() } END { /* Give me top 10 highest counts; throw away rest */ trunc(@, 10) }
/* Count sub entries by package and sub name * arg3 = package name (Foo::Bar) * arg0 = subroutine name (do_something) */ @[strjoin(strjoin(copyinstr(arg3),"::"),copyinstr(arg0))] = count() } END { /* Give me top 10 highest counts; throw away rest */ trunc(@, 10) }
/* Count sub entries by package and sub name * arg3 = package name (Foo::Bar) * arg0 = subroutine name (do_something) */ @[strjoin(strjoin(copyinstr(arg3),"::"),copyinstr(arg0))] = count() } END { /* Give me top 10 highest counts; throw away rest */ trunc(@, 10) }
/* Count sub entries by package and sub name * arg3 = package name (Foo::Bar) * arg0 = subroutine name (do_something) */ @[strjoin(strjoin(copyinstr(arg3),"::"),copyinstr(arg0))] = count() } END { /* Give me top 10 highest counts; throw away rest */ trunc(@, 10) }
DTrace probes! 5.10.1! sub-entry, sub-return! 5.14.x! sub-entry and return get package name as an argument! 5.16.x! phase-change! 5.18.0! op-entry, loading-file, loaded- file!