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

1

13

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

Gay answered 5/6, 2014 at 23:22 Comment(0)
G
7

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.

Gay answered 18/6, 2014 at 0:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.