Rate This Document
Findability
Accuracy
Completeness
Readability

Example

Monitoring Mode

1
devkit diag jvm-jitter -a monitor -e jit.deoptimization -c /home/DevKit-CLI-xx.xx.xx-Linux-Kunpeng/diag/config/kunpeng_devkit.cfg -p 1179
  • The -a monitor parameter specifies the monitoring mode, the -e jit.deoptimization parameter specifies de-optimization event monitoring, the -c parameter specifies the configuration file path, and the -p 1179 parameter specifies the ID of the Java process to be detected. The current working directory is /home/test/workspace/demo.
  • To enable monitoring, set the <enabled> option of the <jvm.DeoptimizationStatistics> parameter in the kunpeng_devkit.cfg file to true, and set the MONITOR_JIT option in the devkit_odin.properties file in the working directory to true. Set other parameters based on your requirements. In this example, <duration> is set to 30 s and <jitTraceThreshold> is set to 0.5.

Command output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
2025-04-11 15:18:29,173 INFO  [jvm-diagnosis-guardian-common-thread-1] c.h.k.devkit.odin.cli.CliWorker: UNIX socket connection established successfully.
2025-04-11 15:18:29,287 INFO  [jvm-diagnosis-profiler-wireIo-thread-1] c.h.k.devkit.odin.cli.CliWorker: other type: CPU_JDBC_METHOD
2025-04-11 15:18:30,968 INFO  [jvm-diagnosis-profiler-wireIo-thread-1] c.h.k.devkit.odin.cli.CliWorker: other type: NONE
2025-04-11 15:18:32,000 INFO  [jvm-diagnosis-profiler-wireIo-thread-1] c.h.k.devkit.odin.cli.CliWorker: JVM_JIT_MONITOR: deoptimizationRatio=0.0, startTime=2025/04/11 PM 03:18:31.925, compileCount=2027, deoptimizationCount=30
2025-04-11 15:18:32,955 INFO  [jvm-diagnosis-profiler-wireIo-thread-1] c.h.k.devkit.odin.cli.CliWorker: JVM_JIT_MONITOR: deoptimizationRatio=5.0, startTime=2025/04/11 PM 03:18:32.925, compileCount=2241, deoptimizationCount=35
2025-04-11 15:18:33,927 INFO  [jvm-diagnosis-profiler-wireIo-thread-1] c.h.k.devkit.odin.cli.CliWorker: JVM_JIT_MONITOR: deoptimizationRatio=0.0, startTime=2025/04/11 PM 03:18:33.925, compileCount=2276, deoptimizationCount=35
2025-04-11 15:18:34,927 INFO  [jvm-diagnosis-profiler-wireIo-thread-1] c.h.k.devkit.odin.cli.CliWorker: JVM_JIT_MONITOR: deoptimizationRatio=0.0, startTime=2025/04/11 PM 03:18:34.926, compileCount=2280, deoptimizationCount=35
2025-04-11 15:18:35,927 INFO  [jvm-diagnosis-profiler-wireIo-thread-1] c.h.k.devkit.odin.cli.CliWorker: JVM_JIT_MONITOR: deoptimizationRatio=0.0, startTime=2025/04/11 PM 03:18:35.926, compileCount=2288, deoptimizationCount=35
...
...
...

Analysis Mode

1
devkit diag jvm-jitter -a report -e jit.deoptimization -f /home/test/workspace/demo/devkit_odin_jfr/devkit_20250411_152001_944.jfr -o /home/test/data

The -a report parameter specifies the analysis mode, the -e jit.deoptimization parameter specifies de-optimization analysis, the -f parameter specifies the path to the JFR file to be analyzed, and the -o /home/test/data parameter specifies the path to the generated flame graph file.

Command output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--------------------------------------------
Reason             Deoptimization methods
--------------------------------------------
loop_limit_check   1
unstable_if        10
class_check        12
-------------------------------------------
Action            Deoptimization methods
-------------------------------------------
maybe_recompile   13
reinterpret       10
-----------------------------------------------------------------------------------------------------------------------------------------
Method                                                     Reason        Action        Instruction Line No.  Compiler  StartTime
-----------------------------------------------------------------------------------------------------------------------------------------
java.io.BufferedReader.readLine(boolean, boolean[])        unstable_if   reinterpret   if_icmplt   330       c2        2025/04/11 PM 03:20:01.994
java.io.ByteArrayOutputStream.ensureCapacity(int)          unstable_if   reinterpret   ifle        99        c2        2025/04/11 PM 03:20:02.000
java.lang.StringLatin1.canEncode(int)                      unstable_if   reinterpret   ifne        54        c2        2025/04/11 PM 03:20:02.009
java.lang.StringBuffer.toString()                          unstable_if   reinterpret   ifeq        716       c2        2025/04/11 PM 03:20:02.462
org.json.JSONObject.isDecimalNotation(String)              unstable_if   reinterpret   if_icmpgt   2204      c2        2025/04/11 PM 03:20:02.469
org.json.JSONObject.isDecimalNotation(String)              unstable_if   reinterpret   if_icmpgt   2204      c2        2025/04/11 PM 03:20:02.469
org.json.JSONObject.writeValue(Writer, Object, int, int)   unstable_if   reinterpret   ifeq        2551      c2        2025/04/11 PM 03:20:02.510
org.json.JSONObject.writeValue(Writer, Object, int, int)   unstable_if   reinterpret   ifeq        2551      c2        2025/04/11 PM 03:20:02.867
test02.App.deserializeJson(String)                         unstable_if   reinterpret   if_icmpge   66        c2        2025/04/11 PM 03:20:05.149
test02.App.serializeJson(List)                             unstable_if   reinterpret   ifeq        93        c2        2025/04/11 PM 03:20:05.401
2025-04-11 15:26:16,419 INFO  [main] c.h.k.d.o.c.r.JitDeoptimizationReport: The above methods support disabling method-level branch prediction to eliminate deoptimization. Usage: -XX:CompileCommand=dontprediction,methodName
2025-04-11 15:26:16,620 INFO  [main] c.h.k.d.o.cli.report.JfrToFlameGraph: The generated flame graph is: /home/test/data/FlameGraph_devkit_20250411_152001_944_20250411152616.html
Table 1 Parameters in a report file

Parameter

Description

Method

Name of the method that triggers de-optimization.

Reason

Cause of de-optimization. unstable_if indicates that branch prediction fails. You can set -XX:CompileCommand=dontprediction,methodName to disable method-level branch prediction so that the specified functions do not generate de-optimization of the unstable_if type.

Action

Operation performed by the JVM for de-optimization, for example:

  • maybe_recompile: triggers method recompilation (the compiler may be replaced).
  • invalidate: invalidates the currently compiled code and rolls back to the interpreter mode.
  • reinterpret: re-parses the method invocation target.

Instruction

Bytecode instruction that triggers de-optimization.

Line No.

Line number of the Java source code that triggers de-optimization.

Compiler

Compiler types that involve de-optimization, for example:

  • c1 (Client Compiler): quick compilation and slight optimization.
  • c2 (Server Compiler): In-depth optimization, suitable for long-term code running.
Figure 1 JIT flame graph