Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid truncated stack traces with Java Flight Recorder

I am using Oracle Java Flight Recorder to collect stack trace samples of a Java application. Theses stack traces allows me to eventually produce a CPU Flamegraph.

My issue is that stack traces deeper than 64 frames are truncated by Java Flight Recorder. It's very easy to observe in the Flamegraph and using a debugger I can observe that no FLRStackTrace has more than 64 FLRFrames and that almost all stack traces with 64 frames have their TruncationState set to TRUNCATED.

Does anyone know if this 64 frames limit can be increased ? Flamegraphs are useless if the stack traces are incomplete.

like image 916
Clément MATHIEU Avatar asked Aug 20 '15 12:08

Clément MATHIEU


People also ask

What is Jfr profiling?

Java Flight Recorder (JFR) is a tool for collecting, diagnosing, and profiling data about a running Java application. It is integrated into the Java Virtual Machine (JVM) and causes almost no performance overhead, so it can be used even in heavily loaded production environments.

How does Jfr work?

JFR collects data from the JVM (through internal APIs) and from the Java application (through the JFR APIs). This data is stored in small thread-local buffers that are flushed to a global in-memory buffer. Data in the global in-memory buffer is then written to disk.


1 Answers

Yep! But not if you're running on JRockit. If running on HotSpot, simply use the flag -XX:FlightRecorderOptions=stackdepth=<n>, where n, as you have discovered, defaults to 64.

More info here: http://hirt.se/blog/?p=364

like image 67
Hirt Avatar answered Oct 02 '22 22:10

Hirt