Monday, September 2, 2013

HotSpot: Using jstat to Explore the Performance Data Memory

HotSpot provides jvmstat instrumentation for performance testing and problem isolation purposes.  And it's enabled by default (see -XX:+UsePerfData).

If you run Java application benchmarks, it's also useful to save PerfData memory to hsperfdata_ file on exit by setting:
  • -XX:+PerfDataSaveToFile
A file named  hsperfdata_<vmid> will be saved in the WebLogic domain's top-level folder.

How to Read hsperfdata File?

To display statistics collected in PerfData memory, you can use:
  • jstat[3]
    • Experimental JVM Statistics Monitoring Tool - It can attach to an instrumented HotSpot Java virtual machine and collects and logs performance statistics as specified by the command line options. (formerly jvmstat)
There are two ways of showing statistics collected in PerfData memory:
  • Online
    • You can attach to an instrumented HotSpot JVM and collect and log performance statistics at runtime.
  • Offline
    • You can set -XX:+PerfDataSaveToFile flag and read the contents of the hsperfdata_ file on the exit of JVM.
In the following, we have shown an offline example of reading the hsperfdata_ file (i.e. a binary file; you need to use jstat[3] to display its content):
$ /scratch/perfgrp/JVMs/jdk-hs/bin/jstat -class file:///<Path to Domain>/MyDomain/hsperfdata_9872

Loaded    Bytes  Unloaded   Bytes       Time
30600   64816.3         2     3.2      19.74

You can check all available command options supported by jstat using:

$jdk-hs/bin/jstat -options

HotSpot Just-In-Time Compiler Statistics

One of the command option supported by jstat is "-compiler", which can provide high-level JIT compiler statistics.

Column Description
Compiled Number of compilation tasks performed.
Failed Number of compilation tasks that failed.
Invalid Number of compilation tasks that were invalidated.
Time Time spent performing compilation tasks.
FailedType Compile type of the last failed compilation.
FailedMethod Class name and method for the last failed compilation.

In the following, we have shown the compiler statistics of three managed servers in one WLS Domain using two different JVM builds:

$/scratch/perfgrp/JVMs/jdk-hs/bin/jstat -compiler file:///<Path to Domain>/MyDomain/hsperfdata_9872


Compiled Failed Invalid   Time   FailedType FailedMethod
   33210     13       0   232.97          1 oracle/ias/cache/Bucket objInvalidate
   74054     20       0   973.03          1 oracle/security/o5logon/b b
   74600     18       0  1094.21          1 oracle/security/o5logon/b b


Compiled Failed Invalid   Time   FailedType FailedMethod
   33287     10       0   246.26          1 oracle/ias/cache/Bucket objInvalidate
   68237     18       0  1022.46          1 oracle/security/o5logon/b b
   67346     18       0   943.79          1 oracle/security/o5logon/b b

Given the above statistics, we could take next action on analyzing why JVM2 generating less compiled methonds than JVM1 did. At least this is one of the use case for using PerfData with its associated tool—jstat.

PerfData-Related JVM Options

UsePerfDataFlag to disable jvmstat instrumentation for performance testing and problem isolation purposes.truebool
PerfDataSaveToFileSave PerfData memory to hsperfdata_ file on exitfalsebool
PerfDataSamplingIntervalData sampling interval in milliseconds50 /*ms*/intx
PerfDisableSharedMemStore performance data in standard memoryfalsebool
PerfDataMemorySizeSize of performance data memory region. Will be rounded up to a multiple of the native os page size.32*Kintx

Note that the default size of PerfData memory is 32K. Therefore the file (i.e., hsperfdata_ file) dumped on exit is also 32K in size.


  1. New Home of Jvmstat Technology
  2. The most complete list of -XX options for Java JVM
  3. jstat - Java Virtual Machine Statistics Monitoring Tool


lee woo said...

Forgiving does not erase the bitter past. A healed memory is not a deleted memory. Instead, forgiving what we cannot forget creates a new way to remember. We change the memory of our past into a hope for our future. See the link below for more info.


Leslie Lim said...

I have a great fun reading your blogs. You are really a great writer. Thank you for making this beautiful and awesome blogs. Hope to read more post from you in the future. Please dont forget to visit me in my site @ Thank you.


Blogger said...

Bluehost is ultimately one of the best web-hosting provider with plans for any hosting requirments.

Blogger said...

Quantum Binary Signals

Professional trading signals sent to your mobile phone daily.

Start following our signals today and make up to 270% per day.