Jdk14 performance management tool: introduction to jstat

brief introduction

As a programmer, I often worry about how to locate problems in Java programs or tune JVM performance. Maybe you've heard of some powerful tools of Java profile, such as jprofile. But most of these tools are charged, which is very unfriendly to our personal programmers.

In fact, JDK has brought many excellent performance tuning tools, which you can use in Java_ Find them in home / bin.

More highlights:

Today's article series is about these four tools:

With these four tools, basically all aspects of the JVM running can be covered. Next, we will explain each tool in detail. This article will first explain the specific use of jstat.

Jstat command

Jstat mainly collects various parameters during the operation of the JVM, including viewing the loading of classes, the usage of metadata space of the new and old generations in JC, etc.

First look at the command of jstat:

jstat outputOptions [-t] [-h lines] vmid [interval [count]]

jstat Output Options

We talked about the basic format of jstat command above. In this section, we will explain the output options of jstat in detail.

Using jstat - options, you can see several options supported by jstat:

jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcMetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation

class

Output the statistics of class loader. Let's take an example:

jstat -class -t 53528 100 5
Timestamp       Loaded  Bytes  Unloaded  Bytes     Time
        19822.8   5214 10752.5        0     0.0       2.91
        19823.0   5214 10752.5        0     0.0       2.91
        19823.0   5214 10752.5        0     0.0       2.91
        19823.2   5214 10752.5        0     0.0       2.91
        19823.2   5214 10752.5        0     0.0       2.91

In the above example, 53528 is the PID of the target JVM, 100 indicates that the sampling interval is 100ms, and 5 indicates that only 5 pieces of data are displayed at last.

The timestamp above indicates the start time of the JVM.

compiler

The compiler counts the information of Java hotspot VM just in time JIT instant compiler.

JIT real-time compiler is produced to improve the execution speed of code. JVM for some hot code, such as multiple loops and frequently used methods. For these hot codes, the JIT will compile them into machine code to improve the execution speed.

Let's take the JVM example just now:

jstat -compiler 53528 100 5
Compiled Failed Invalid   Time   FailedType FailedMethod
    2675      0       0     5.35          0
    2675      0       0     5.35          0
    2675      0       0     5.35          0
    2675      0       0     5.35          0
    2675      0       0     5.35          0

gc

GC counts the GC heap information

jstat -gc 53528 100 5
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT    CGC    CGCT     GCT
 0.0   4096.0  0.0   3978.2 56320.0  33792.0   15360.0    15215.0   21552.0 20680.9 2688.0 2468.0      4    0.025   0      0.000   2      0.003    0.028
 0.0   4096.0  0.0   3978.2 56320.0  33792.0   15360.0    15215.0   21552.0 20680.9 2688.0 2468.0      4    0.025   0      0.000   2      0.003    0.028
 0.0   4096.0  0.0   3978.2 56320.0  33792.0   15360.0    15215.0   21552.0 20680.9 2688.0 2468.0      4    0.025   0      0.000   2      0.003    0.028
 0.0   4096.0  0.0   3978.2 56320.0  33792.0   15360.0    15215.0   21552.0 20680.9 2688.0 2468.0      4    0.025   0      0.000   2      0.003    0.028
 0.0   4096.0  0.0   3978.2 56320.0  33792.0   15360.0    15215.0   21552.0 20680.9 2688.0 2468.0      4    0.025   0      0.000   2      0.003    0.028

There are many output parameters of GC. Let's explain them one by one, so that we can have a better understanding of the running kernel of GC:

gccapacity

Gccapacity counts the creation and size of memory pools

jstat -gccapacity 53528 100 5
 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC       MCMN     MCMX      MC     CCSMN    CCSMX     CCSC    YGC    FGC   CGC
     0.0 716800.0  60416.0    0.0 4096.0  56320.0        0.0   716800.0    15360.0    15360.0      0.0 1069056.0  21552.0      0.0 1048576.0   2688.0      4     0     2
     0.0 716800.0  60416.0    0.0 4096.0  56320.0        0.0   716800.0    15360.0    15360.0      0.0 1069056.0  21552.0      0.0 1048576.0   2688.0      4     0     2
     0.0 716800.0  60416.0    0.0 4096.0  56320.0        0.0   716800.0    15360.0    15360.0      0.0 1069056.0  21552.0      0.0 1048576.0   2688.0      4     0     2
     0.0 716800.0  60416.0    0.0 4096.0  56320.0        0.0   716800.0    15360.0    15360.0      0.0 1069056.0  21552.0      0.0 1048576.0   2688.0      4     0     2
     0.0 716800.0  60416.0    0.0 4096.0  56320.0        0.0   716800.0    15360.0    15360.0      0.0 1069056.0  21552.0      0.0 1048576.0   2688.0      4     0     2

gcnew

Gcnew represents the statistics of the Cenozoic

jstat -gcnew 53528 100 5
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT
   0.0 4096.0    0.0 3978.2 15  15 5120.0  56320.0  33792.0      4    0.025
   0.0 4096.0    0.0 3978.2 15  15 5120.0  56320.0  33792.0      4    0.025
   0.0 4096.0    0.0 3978.2 15  15 5120.0  56320.0  33792.0      4    0.025
   0.0 4096.0    0.0 3978.2 15  15 5120.0  56320.0  33792.0      4    0.025
   0.0 4096.0    0.0 3978.2 15  15 5120.0  56320.0  33792.0      4    0.025

gcnewcapacity

Gcnewcapacity counts the indicators of the Cenozoic generation, which is very similar to the results of gccapacity:

jstat -gcnewcapacity 53528 100 5
  NGCMN      NGCMX       NGC      S0CMX     S0C     S1CMX     S1C       ECMX        EC      YGC   FGC   CGC
       0.0   716800.0    60416.0      0.0      0.0 716800.0   4096.0   716800.0    56320.0     4     0     2
       0.0   716800.0    60416.0      0.0      0.0 716800.0   4096.0   716800.0    56320.0     4     0     2
       0.0   716800.0    60416.0      0.0      0.0 716800.0   4096.0   716800.0    56320.0     4     0     2
       0.0   716800.0    60416.0      0.0      0.0 716800.0   4096.0   716800.0    56320.0     4     0     2
       0.0   716800.0    60416.0      0.0      0.0 716800.0   4096.0   716800.0    56320.0     4     0     2

gcold

Gcold counts the information of old generation

jstat -gcold 53528 100 5
   MC       MU      CCSC     CCSU       OC          OU       YGC    FGC    FGCT    CGC    CGCT     GCT
 21552.0  20680.9   2688.0   2468.0     15360.0     15215.0      4     0    0.000     2    0.003    0.028
 21552.0  20680.9   2688.0   2468.0     15360.0     15215.0      4     0    0.000     2    0.003    0.028
 21552.0  20680.9   2688.0   2468.0     15360.0     15215.0      4     0    0.000     2    0.003    0.028
 21552.0  20680.9   2688.0   2468.0     15360.0     15215.0      4     0    0.000     2    0.003    0.028
 21552.0  20680.9   2688.0   2468.0     15360.0     15215.0      4     0    0.000     2    0.003    0.028

Several indicators of the results have been introduced earlier, and will not be repeated here

gcoldcapacity

Gcoldcapacity indicates the capacity information of the old generation

jstat -gcoldcapacity 53528 100 5
   OGCMN       OGCMX        OGC         OC       YGC   FGC    FGCT    CGC    CGCT     GCT
        0.0    716800.0     15360.0     15360.0     4     0    0.000     2    0.003    0.028
        0.0    716800.0     15360.0     15360.0     4     0    0.000     2    0.003    0.028
        0.0    716800.0     15360.0     15360.0     4     0    0.000     2    0.003    0.028
        0.0    716800.0     15360.0     15360.0     4     0    0.000     2    0.003    0.028
        0.0    716800.0     15360.0     15360.0     4     0    0.000     2    0.003    0.028

gcMetacapacity

Gcmetacapacity counts the capacity information of the metadata area

jstat -gcMetacapacity 53528 100 5
   MCMN       MCMX        MC       CCSMN      CCSMX       CCSC     YGC   FGC    FGCT    CGC    CGCT     GCT
       0.0  1069056.0    21552.0        0.0  1048576.0     2688.0     4     0    0.000     2    0.003    0.028
       0.0  1069056.0    21552.0        0.0  1048576.0     2688.0     4     0    0.000     2    0.003    0.028
       0.0  1069056.0    21552.0        0.0  1048576.0     2688.0     4     0    0.000     2    0.003    0.028
       0.0  1069056.0    21552.0        0.0  1048576.0     2688.0     4     0    0.000     2    0.003    0.028
       0.0  1069056.0    21552.0        0.0  1048576.0     2688.0     4     0    0.000     2    0.003    0.028

gcutil

Gcutil counts the overall situation of GC

jstat -gcutil 53528 100 5
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT    CGC    CGCT     GCT
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028

gccause

Gccause and gcutil are very familiar, except for the following two columns:

jstat -gccause 53528 100 5
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT    CGC    CGCT     GCT    LGCC                 GCC
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028 Metadata GC Threshold No GC
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028 Metadata GC Threshold No GC
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028 Metadata GC Threshold No GC
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028 Metadata GC Threshold No GC
  0.00  97.12  60.00  99.06  95.96  91.82      4    0.025     0    0.000     2    0.003    0.028 Metadata GC Threshold No GC

printcompilation

Printcompilation is the JVM compiler's method statistics

jstat -printcompilation 53528 100 5
Compiled  Size  Type Method
    2675     23    1 jdk/internal/misc/InnocuousThread eraseThreadLocals
    2675     23    1 jdk/internal/misc/InnocuousThread eraseThreadLocals
    2675     23    1 jdk/internal/misc/InnocuousThread eraseThreadLocals
    2675     23    1 jdk/internal/misc/InnocuousThread eraseThreadLocals
    2675     23    1 jdk/internal/misc/InnocuousThread eraseThreadLocals
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>