Usage | Overview |
-------------------------------- | ------------- |
CPU profiling | TPROF |
CPU Utilization | AI |
Java Pathlength Profiling | JPROF |
Java Object Profiling with Full Call Tree | JPROF |
Java Object Profiling with Reduced Call Tree | JPROF |
Java Profiling via Monitor Events | JPROF |
Java Callflow (Generic) | JPROF |
Java Lock Monitor | JLM |
Heap dump | HDUMP |
Instruction Tracing | ITRACE |
Record and Playback | JPROF |
Training Calibration | trainer |
All of the following examples use the JVM Tools Interface (JVMTI) to invoke our Java Profiler (JPROF). JVMTI is available on all Java versions beginning with Java 5. JVMTI replaced the JVM Profiler Interface (JVMPI), which is no longer supported after Java 5.
To use JVMPI instead of JVMTI, simply replace -agentlib:jprof= with -Xrunjprof: wherever it appears below.
If it is a Java application, use the following command:
java -agentlib:jprof=tprof[,logpath=path] classfile
java -agentlib:jprof=callflow[,start][,logpath=path] classfile
java -agentlib:jprof=calltree,objectinfo[,hr][,sobjs][,start][,logpath=path] classfile
Lines describing allocated objects are added after each node in the calltree where an allocation occurs. These lines use logical metrics for AllocatedObjects, AllocatedBytes, LiveObjects, and LiveBytes and display the class of the object, in parentheses, in same field that would have contained the name of the method.
java -agentlib:jprof=scs=allocated_bytes[=nn],objectinfo[,hr][,sobjs][,start][,logpath=path] classfile
Lines describing allocated objects are added after each node in the calltree where an allocation occurs. These lines use logical metrics for AllocatedObjects, AllocatedBytes, LiveObjects, and LiveBytes and display the class of the object, in parentheses, in same field that would have contained the name of the method.
java -agentlib:jprof=scs=monitor_contended_entered[+][=nn][,hr][,start][,logpath=path] classfile
The calibrated number of instructions is an estimate of the number of instructions which would have been executed if you were not using JPROF.
java -agentlib:jprof=gencalib[,metrics=raw_cycles][,start][,logpath=path] classfile
start begins data collection immediately, instead of waiting until start is received from rtdriver.
java -agentlib:jprof=[,logpath=path] classfile
java -agentlib:jprof=ehd[,logpath=path] classfile
If it is a Java application, use the following command:
java -agentlib:jprof=itrace[,logpath=path] classfile
java -agentlib:jprof=callflow,record[,objectinfo][,start][,logpath=path] classfile
If the start option is specified when JPROF is invoked, training can usually be achieved by simply observing JVM startup. However, profiling is usually started only after the application has been "warmed up" and frequently used methods have already been compiled by the JIT. In those cases, there will probably not be time to properly train the calibration routines before they are needed.
The calstats= and usestats= options are used to calculate, save, and restore the results of calibration training sessions. The calstats=filename option, defines a file for recording calibration statistics. If the file already exists, it will use the previous statistics and update them as needed. If the file does not exist, it will create it. The usestats=filename option, also reads the previous statistics, but makes no attempt to update the statistics, in an attempt to minimize overhead while profiling.
To be useful, training and profiling must be performed using nearly identical JPROF options. That is, the version, platform, and JVM information in the calstats file header must match the current environment. The metrics recorded in the calstats file must also match the metrics used when profiling. You will need to create a unique calstats file for each unique configuration you plan to use.
Typically, calstats= is used during training, such as:
while usestats= is used during profiling, such as:
trainer is a Java program that was specifically designed to train the calibration routines by providing repeated examples of the most common sequences of JVM events. Most of the examples in trainer make nested calls 20 levels deep in an attempt to exceed the limits of any optimizer that would attempt to inline the sequences we are trying to calibrate.
Over time, trainer also evolved into an example which demonstrates how to control JPROF programmatically. The .java and .class files for trainer are included in the packages for all platforms.
The syntax for invoking trainer, which can be displayed using the "-?" parameter, is as follows:
where: