Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable Java stack frame optimizations, or profile stacks using system profilers?

System profilers, like DTrace and Linux perf_events, are able to profile stack traces from the JVM. Now, symbols aside (that's another problem), both DTrace and perf_events collect many stacks that are only 1 frame. These are partial, incomplete stacks.

I've tried DTrace jstack(), and Linux perf_events with both frame pointer and dwarf stack unwinding.

I believe this is due to hotspot compiling optimized frames. Is there a way to disable this optimization, so that standard system profilers (like Solaris DTrace, and Linux perf) work?

I've already tried the following options: -XX:+DeoptimizeRandom -XX:MaxInlineSize=0 -XX:-OmitStackTraceInFastThrow -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames

like image 329
Brendan Gregg Avatar asked Jun 05 '14 23:06

Brendan Gregg


1 Answers

This is a JVM issue, and is best described by bug:

https://bugs.openjdk.java.net/browse/JDK-6276264

While that describes the problem with DTrace jstack(), I believe the same optimization (using the frame pointer as a register) is breaking perf_events.

This may be fixed in JDK 9. See:

http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2014-June/014842.html

Thanks to the hotspot developers for answering this.

like image 194
Brendan Gregg Avatar answered Sep 30 '22 12:09

Brendan Gregg