The Java DTrace Toolkit
DTrace is a dynamic tracing framework, initially developed by Sun for the Solaris 10 OS. Since some early beta version of the Java 1.6 JDK, the JVM (at least on Solaris) has incorporated a number of DTrace probes that allow DTrace to extract data from a program running within the JVM at runtime.
I initially used DTrace for Java to study the interaction of the OS with the JVM on the I/O front. I then understood that my scripts might be useful to a number of people doing low level performance analysis so I spent some time to make them a bit more generic and easy to use.
You can download the Java DTrace Toolkit from here
The JDT has been presented in the following short paper:
G. Gousios and D. Spinellis, “Java Performance Evaluation Using External Instrumentation,” in Proceedings of the 12th Pan-Hellenic Conference on Informatics, 2008, pp. 173–177.
###The scripts
Script | Function |
jprofiler | Reports the methods and classes that consume most execution time. Can aggregate results by package name. |
jmemstats | Report object allocation statistics. Can aggregate results by package name and filter results by specific package names. |
jlockstat | Reports methods initiating locking opera- tions in native code. |
jiosnoop | File management statistics: which classes cause I/O traffic? |
jcallgraph | Display a Java function call graph from Java to the OS kernel. |
jgcsnoop | Reports garbage collection statistics: frequency, duration. |
###Output examples
####jmemstats
Java Method objects alloc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
java/lang/StringCoding$StringEncoder.encode 486
java/util/HashMap.newKeyIterator 221
org/[...]/buf/CharChunk.toStringInternal 142
java/io/UnixFileSystem.resolve 131
java/lang/String.substring 122
java/lang/StringCoding$StringDecoder.decode 108
java/net/Socket.getInputStream 100
java/lang/AbstractStringBuilder.expandCapacity 99
java/lang/Object.clone 91
java/io/UnixFileSystem.list 74
####jlockstat
Java Method Native cnt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
java/io/UnixFileSystem.getBooleanAttributes0 malloc 367
java/io/UnixFileSystem.getBooleanAttributes0 free 363
java/lang/ClassLoader.defineClass1 free 288
java/lang/ClassLoader.defineClass1 malloc 290
java/io/UnixFileSystem.getLastModifiedTime free 136
java/io/UnixFileSystem.getLastModifiedTime malloc 136
java/io/UnixFileSystem.list readdir64_r 134
####jiosnoop
Java Method syscall cnt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
org/apache/coyote/Response.action _so_send 7
org[...]Http11Processor.action _read 7
org/[...]OutputStreamOutputBuffer.doWrite _so_send 2
org/[...]Http11ConnectionHandler.processConnect _read 1
org[...]/mapper/Mapper.internalMapWrapper _read 1