不能,在使用 -javaagent 和 -XX:StartFlightRecording 参数启动JVM时,Java Agent 会先于 JFR 初始化,因此 JFR 无法记录 到Java Agent 初始化的资源消耗。如果对 Java Agent 启动性能有监控需求,可能需要寻找其他方法来实现。
参考 JDK 源码:https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/threads.cpp
// Notify JVMTI agents that VM initialization is complete - nop if no agents. JvmtiExport::post_vm_initialized(); JFR_ONLY(Jfr::on_create_vm_3();)
可以,默认配置:https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/conf/jfr/default.jfc
<event name="jdk.CompilerConfiguration"> <setting name="enabled" control="compiler-enabled">true</setting> <setting name="period">beginChunk</setting> </event> <event name="jdk.CompilerStatistics"> <setting name="enabled" control="compiler-enabled">true</setting> <setting name="period">1000 ms</setting> </event> <event name="jdk.Compilation"> <setting name="enabled" control="compiler-enabled">true</setting> <setting name="threshold" control="compiler-compilation-threshold">1000 ms</setting> </event> <event name="jdk.CompilerPhase"> <setting name="enabled" control="compiler-enabled">true</setting> <setting name="threshold" control="compiler-phase-threshold">60 s</setting> </event> <event name="jdk.CompilationFailure"> <setting name="enabled" control="compiler-enabled-failure">false</setting> </event> <event name="jdk.CompilerInlining"> <setting name="enabled" control="compiler-enabled-failure">false</setting> </event> <event name="jdk.JITRestart"> <setting name="enabled" control="compiler-enabled">true</setting> </event> <event name="jdk.CodeCacheConfiguration"> <setting name="enabled" control="compiler-enabled">true</setting> <setting name="period">beginChunk</setting> </event> <event name="jdk.CodeCacheStatistics"> <setting name="enabled" control="compiler-enabled">true</setting> <setting name="period">everyChunk</setting> </event> <event name="jdk.CodeCacheFull"> <setting name="enabled" control="compiler-enabled">true</setting> </event>
可以查看:
还可以通过 JIT 编译日志了解:
个人简介:个人业余研究了 AI LLM 微调与 RAG,目前成果是微调了三个模型: