监测分析Java程序示例
监测模式
          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  | 
        
 
     参数-a monitor指定为监测模式,参数-e jit.deoptimization指定监测退优化事件,参数-c指定配置文件路径,参数-p 1179指定待监测Java进程的进程号,当前工作目录为/home/test/workspace/demo。
修改工作目录下的devkit_odin.properties文件,需修改文件中的MONITOR_JIT为true来开启监控。
返回信息如下:
          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: Success to build unixSocket connect 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 ... ... ...  | 
        
分析模式
          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  | 
        
 
     参数-a report指定为分析模式,参数-e jit.deoptimization指定分析退优化事件,参数-f指定待分析的jfr文件路径,参数-o /home/test/data指定火焰图文件生成路径。
返回信息如下:
          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  | 
        
| 
          报告参数  | 
        
          说明  | 
       
|---|---|
| 
          Method  | 
        
          触发退优化的方法名称。  | 
       
| 
          Reason  | 
        
          触发退优化的原因。unstable_if为分支预测失效,可使用参数“-XX:CompileCommand=dontprediction,methodName”进行方法级分支预测禁用,让指定的函数不产生unstable_if类型的退优化。  | 
       
| 
          Action  | 
        
          JVM针对退优化采取的具体操作,例如: 
  | 
       
| 
          Instruction  | 
        
          触发退优化的字节码指令。  | 
       
| 
          Line No.  | 
        
          触发退优化的Java源码行号。  | 
       
| 
          Compilers  | 
        
          涉及退优化的编译器类型,例如: 
  | 
       
     图1 JIT火焰图
     
    
   
    
     父主题: JVM性能波动诊断