ktoso/sbt-jmh contains JMH profilers based on Java Flight Recorder and async-profiler. These would be useful for all JMH users, not just the subset using it through SBT. There is interest in at least getting async-profiler support to upstream JMH.
Existing Docs
Using Oracle Flight Recorder
Flight Recorder / Java Mission Control is an excellent tool shipped by default in the Oracle JDK distribution.
It is a profiler that uses internal APIs (commercial) and thus is way more precise and detailed than your every-day profiler.
To record a Flight Recorder file from a JMH run run it using the jmh.extras.JFR profiler:
Where /code/FlameGraph and /code/jfr-flame-graph need to reflect actual paths of those tools on your system.
Upstreaming Plan
Async Profiler
[x] Update the option parser in sbt-jmh to reflect what's available in the latest version of async-profiler
[x] Review the best way to start/stop the profiler. Currently it calls $ASYNC_PROFILER_HOME/jattach load true <command>. There are other ways to do this now, not sure if they improve simplicity, portability, etc.
[x] Review the integrated flame graph generation. A minimal version would remove the wrapper around flamegraph.pl. Users could either use the built-in flamegraph support that was since added to async-profiler, or post-process collapsed-stacks.csv themselves with flamegraph.pl.
Java Flight Recorder
[x] Remove the automatic setting of UnlockCommercialFeatures. Require Oracle JDK users to add this with -jvmArgs.
ktoso/sbt-jmh contains JMH profilers based on Java Flight Recorder and async-profiler. These would be useful for all JMH users, not just the subset using it through SBT. There is interest in at least getting async-profiler support to upstream JMH.
Existing Docs
Using Oracle Flight Recorder
Flight Recorder / Java Mission Control is an excellent tool shipped by default in the Oracle JDK distribution. It is a profiler that uses internal APIs (commercial) and thus is way more precise and detailed than your every-day profiler.
To record a Flight Recorder file from a JMH run run it using the
jmh.extras.JFR
profiler:All options can be discovered by running the help task:
This will result in flight recording file which you can then open and analyse offline using JMC.
Example output:
Export JFR to specific directory:
Using async-profiler
Using async profiler is done by using the
jmh.extras.Async
profiler like this:All additional options are documented in it's help task:
Automatically generating flame-grapghs
Read more about flame graphs here:
To automatically generate flame graphs for a given benchmark you can invoke:
Where
/code/FlameGraph
and/code/jfr-flame-graph
need to reflect actual paths of those tools on your system.Upstreaming Plan
Async Profiler
$ASYNC_PROFILER_HOME/jattach load true <command>
. There are other ways to do this now, not sure if they improve simplicity, portability, etc.Java Flight Recorder
UnlockCommercialFeatures
. Require Oracle JDK users to add this with-jvmArgs
.