This test shows the performance impact of 2 different (logging) code patterns.
SimpleInliningTest::wrongLong
is supposed to be too big (bytecode wise) to be inlined; it can be verified using:
- the compilation log by running the application with
-XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining
- JITWatch by copying the source as it is into the SandBox and playing with it
notes: it uses an ancient and unsafe technique to avoid dead code removal, JMH would be better, but JitWatch's Sandbox is the main consumer of this.
The profilers that worths to be tried are:
- JVisualVM CPU Sample Profiler:
JvmtiEnv::GetAllStackTraces
based - perf-map-agent: "mostly" perf based
- async-profiler:
AsyncGetCallTrace
+ perf hybrid
The instruction for the perf-map-agent
case are packed directly in the javadoc of the test.
In summary:
JVisualVM
could just samples Java stack while on safepointperf-map-agent
usesperf
, can profile any stack (native + Java), but need to force the JVM to preserve the frame pointer and could read broken framesasync-profiler
usesperf
for native (JVM/Kernel) calls whileAsyncGetCallTrace
for Java ones (JFR
,Solaris Studio
do the same) trying to match between the two worlds (could read broken frames on both sides)
notes: Please remember to kill it or it will kill your CPU!!!!Hot stuff
It is mostly based on the awesome Nitsan Wakart article and it helps
to understand how most legends around byte[]
common operations are false and need proper (and correct) measurements.