0

How to launch jstat?

jstat is a simple utility tool, that is present in JDK to provide JVM performance-related statistics like garbage collection, compilation activities. The major strength of jstat is its ability to capture these metrics dynamically when JVM is running without any pre-requisite instrumentation. What do we mean by it? Say for example if you want to capture garbage collection related statistics, you need to pass below arguments before you start the JVM:

 -Xlog:gc*:file={file-path}

 

This argument will enable GC logs and print them in the specified file path. Say suppose you haven’t passed this argument, then GC related statistics will not be generated. This is where jstat can come handy. Dynamically you can connect to JVM and capture GC, compilation related statistics as shown below.

How to launch jstat?

Execute below command. It’s a simple option to launch jstat.

 jstat -gc -t 11656 10000 30

-gc: garbage collection related statistics will be printed

-t timestamp since JVM was started will be printed

11656: target JVM process Id

10000: statistics will be printed every 10,000 milliseconds (i.e. 10 seconds).

30: statistics will be printed for 30 iterations. Thus, the above option will cause the JVM to print metrics for 300 seconds (i.e. 10 seconds x 30 iterations).

(Note besides -gc, you can pass various other options to generate different data sets. For more details on different options, you refer here.)

Data generated by jstat

When you launch jstat with above options, here is the output that will be generated:

                                                Fig: jstat output

 

Timestamp – time since the start time of the target JVM in seconds.

S0C – Survivor 0 region capacity in KB

S1C – Survivor 1 region capacity in KB

S0U – Survivor 0 region utilized space in KB

S1U – Survivor 1 region utilized space in KB

EC – Eden region capacity in KB

EU – Eden region’s utilized space in KB

OC – Old region capacity in KB

OU – Old region’s utilized space in KB

MC – Metaspace region capacity in KB

MU – Metaspace region utilized space in KB

CCSC – Compressed Class space regions capacity in KB

CCSU – Compressed Class space regions utilized space in KB

YGC – Number of Young GC events that have occurred so far

YGCT – Amount of Young GC time spent so far

FGC – Number of Full GC events that have occurred so far

FGCT – Amount of Full GC time spent so far

GCT – total amount of GC time spent so far (basically YGCT + FGCT)

How to interpret jstat output?

Equipped with this information let’s try to interpret the first line printed by the jstat tool in the above example:

                         

                                             Fig: jstat output’s first line

 

Tool to analyze jstat output

One challenge with jstat is you need to manually analyze the generated statistics. It will be tedious, as you can see just to understand/interpret one single line it takes a quite long time. You can use GCeasy tool, which can parse jstat output and generate insightful graphs and metrics. Here is the jstat analysis report generated by GCeasy by analyzing above jstat output.

 

Read More: Limitation of jstat

 

0 comments

Please sign in to leave a comment.