Dtrace with Solaris10
March 18, 2007 – 6:58 pm
Dynamic Tracing (DTrace) is a debugging tool introduced in the Solaris 10 Operating System to help debug systemic problems that are difficult to diagnose using traditional debugging tools and mechanisms. This tool
takes advantage of points of instrumentation in the Solaris OS to present information useful for debugging errors and investigating performance issues in applications running on the Solaris OS.
Although it's been around for about 2 years, DTrace hasn't really caught on as a standard tool for performance testing, but it's only a matter of time. Sun's Java 6 Hotspot JVM has built-in DTrace providers which will make it the easiest and best tool to use for diagnosing J2EE application server problems. Instead of complicated (and for commercial products, expensive) instrumentation and profiling tools, DTrace can provide the ability to provide the same information with a few small commands or scripts. If you aren't using Java 6, you can still take advantage of DTrace capabilities using a DTrace VM Agent, althought it's not recommended for production usage.
Sample Scripts
Here are some sample DTrace scripts that I have used to debug a weblogic application server, using the DTrace VM Agent.
Object Allocation sizes
This one-liner will show you the size and frequency of object allocations (for the most recent java process)
# dtrace -n 'djvm$target:::object-alloc{ @ = quantize(arg1) }' -p `pgrep -n java`
dtrace: description 'djvm$target:::object-alloc' matched 1 probe
^C
value ————- Distribution ————- count
4 | 0
8 | 43
16 |@@@@@@@@@@@@@@@@@ 18771
32 |@@@@@@@@@@@@@@@@ 17482
64 |@@@@@ 5292
128 |@ 1486
256 | 106
512 | 165
1024 | 319
2048 | 149
4096 | 48
8192 | 0
16384 | 1
32768 | 1
65536 | 0
Stack Trace
Now, say you wanted to drill down and find out what that object allocation was between 16KB and 32KB, you could run this one-liner:
# dtrace -n 'dvm$target:::object-alloc /quantive(arg1)>16384/ { jstack(); }' -p `pgrep -n java`
DTrace Architecture:


{mos_sb_discuss:11}
