SourceForge.net Logo
Home

Performance Inspector Examples

UsageOverview
--------------------------------     -------------
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.


CPU Profiling (TProf)


CPU Utilization (AI)

    1. Execute swtrace ai

    2. Output is written to stdout

      swtrace


Java Pathlength Profiling

    1. Start your Java application with the following command:

      java   -agentlib:jprof=callflow[,start][,logpath=path]   classfile

      • callflow   implies metrics=ptt_insts+ptt_cycles. See Metrics for a discussion about metric selection.

      • start begins data collection immediately, instead of waiting until start is received from rtdriver.

      • logpath=path sets the path directory as the location for the JPROF output files. Use the appropriate slash ("/" or "\") for your operating system.

    2. For runtime control, you can execute rtdriver -l in another window. The following commands can be used:

      • start - Starts data collection.
      • end - Ends data collection, writes the data that has been collected, then resets all internal buffers.
      • flush - Writes the data that has been collected, but does not end or reset data collection.

    3. Output in log-rt.1_pid
    4. jprof . rtdriver


Java Object Profiling with Full Call Tree

    1. Start your Java application with the following command:

      java   -agentlib:jprof=calltree,objectinfo[,hr][,sobjs][,start][,logpath=path]   classfile

      • calltree is used with object profiling because it implies nometrics, which turns off the metrics that are not required for this kind of profiling.

      • objectinfo indicates that we are interested in tracking both object allocations and frees. It also implies nomethodtypes, which eliminates the distinction between interpreted and compiled methods.

        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.

      • hr or humanreadable adds extra blank lines around the lines describing the allocated objects to improve readability.

      • The sobjs option separates objects of the same class by size.

      • start begins data collection immediately, instead of waiting until start is received from rtdriver.

      • logpath=path sets the path directory as the location for the JPROF output files. Use the appropriate slash ("/" or "\") for your operating system.

    2. For runtime control, you can execute rtdriver -l in another window. The following commands can be used:

      • start - Starts data collection.
      • end - Ends data collection, writes the data that has been collected, then resets all internal buffers.
      • flush - Writes the data that has been collected, but does not end or reset data collection.

    3. Output is in log-rt.1_pid

      jprof . rtdriver


Java Object Profiling with Reduced Call Tree

    This feature is available only after JPROF version 8.8.0 and only using JVMTI.

    1. Start your Java application with the following command:

      java   -agentlib:jprof=scs=allocated_bytes[=nn],objectinfo[,hr][,sobjs][,start][,logpath=path]   classfile

      • Rather than instrumenting every method entry and exit, scs=allocated_bytes samples the current call stack only when objects are allocated. This produces callflow trees only down to those places where objects are allocated.

      • Adding =nn samples the call stack only after nn or more bytes have been allocated. This can result in much fewer samples and faster execution, but it also means that only some of the allocations and frees are actually recorded. This option is useful when profiling very large applications.

      • objectinfo indicates that we are interested in tracking both object allocations and frees. It also implies nomethodtypes, which eliminates the distinction between interpreted and compiled methods.

        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.

      • hr or humanreadable adds extra blank lines around the lines describing the allocated objects to improve readability.

      • The sobjs option separates objects of the same class by size.

      • start begins data collection immediately, instead of waiting until start is received from rtdriver.

      • logpath=path sets the path directory as the location for the JPROF output files. Use the appropriate slash ("/" or "\") for your operating system.

    2. For runtime control, you can execute rtdriver -l in another window. The following commands can be used:

      • start - Starts data collection.
      • end - Ends data collection, writes the data that has been collected, then resets all internal buffers.
      • flush - Writes the data that has been collected, but does not end or reset data collection.

    3. Output is in log-rt.1_pid

      jprof . rtdriver


Java Profiling via Monitor Events

    This feature is available only after JPROF version 8.8.0 and only using JVMTI.

    1. Start your Java application with the following command:

      java   -agentlib:jprof=scs=monitor_contended_entered[+][=nn][,hr][,start][,logpath=path]   classfile

      • Rather than instrumenting every method entry and exit, scs=contended_monitor_entered samples the current call stack only when a MONITOR_CONTENDED_ENTERED event is received. This produces callflow trees only down to those places where the events were received.

      • The + indicates that you want to display the object classes associated with the events.

      • Adding =nn samples the call stack only after nn or more events have been received. This can result in much fewer samples and faster execution, but it also means that only some of the events are actually recorded. This option is useful when profiling very large applications.

      • hr or humanreadable, when used with the + option, improves readability by adding extra blank lines around the lines describing the object classes associated with the events.

      • start begins data collection immediately, instead of waiting until start is received from rtdriver.

      • logpath=path sets the path directory as the location for the JPROF output files. Use the appropriate slash ("/" or "\") for your operating system.

    2. For runtime control, you can execute rtdriver -l in another window. The following commands can be used:

      • start - Starts data collection.
      • end - Ends data collection, writes the data that has been collected, then resets all internal buffers.
      • flush - Writes the data that has been collected, but does not end or reset data collection.

    3. Output is in log-rt.1_pid

      jprof . rtdriver


Java CallFlow (Generic/Gencalib)


Java Lock Monitor

    1. Start your Java application with the following command:

      java   -agentlib:jprof=[,logpath=path]   classfile

      • logpath=path sets the path directory as the location for the JPROF output files. Use the appropriate slash ("/" or "\") for your operating system.

    2. For runtime control, you must execute rtdriver -l in another window

      • jlm | jlmstart
      • jlml | jlmstartlite
      • jd | jlmdump
      • jreset | jlmreset
      • jstop | jlmstop

    3. Output is in log-jlm.n

      jlm . jprof . rtdriver


Heapdump


Instruction Trace ( ITrace )

    Instruction trace (ITrace) is performed by the following steps:

    1. Execute run.itrace in a window and follow the prompts until you are asked to press Enter to begin tracing.

    2. Start your application in another window.

      If it is a Java application, use the following command:

      java   -agentlib:jprof=itrace[,logpath=path]   classfile

      • logpath=path sets the path directory as the location for the JPROF output files. post requires a corresponding -jdir path/log option to locate these files. Use the appropriate slash ("/" or "\") for your operating system.

    3. Press Enter when you are ready to begin tracing.

    4. Press Enter again when you are ready to end tracing.

      swtrace . itrace . post . jprof


Record and Playback

    1. To record all events for later playback, start your Java application with the following command:

      java   -agentlib:jprof=callflow,record[,objectinfo][,start][,logpath=path]   classfile

      • callflow puts JPROF in normal callflow gathering mode.

      • record sends a record of all events to log-trace and turns off tree building.

      • objectinfo can be used to record object allocations and frees.

      • start begins data collection immediately, instead of waiting until start is received from rtdriver.

      • logpath=path sets the path directory as the location for the JPROF output files. Use the appropriate slash ("/" or "\") for your operating system.

    2. For runtime control, you can execute rtdriver -l in another window. The following commands can be used:

      • start - Starts data collection.
      • end - Ends data collection, writes the data that has been collected, then resets all internal buffers.
      • flush - Writes the data that has been collected, but does not end or reset data collection.

    3. All output is placed in log-trace_pid.

    4. To playback the events into normal JPROF output files, use the following command:

        java   -agentlib:jprof=playback=pid

      jprof


Training Calibration

Home