How to avoid truncated stack traces with Java Flight Recorder
Asked Answered
L

1

8

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.

Life answered 20/8, 2015 at 12:45 Comment(0)
R
9

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

Romany answered 21/8, 2015 at 8:40 Comment(3)
Thanks Marcus ! Any chance to be able to configure that at run time in the future ? I am a huge fan of the MBean feature and it would be great to be able to pass this as an option to jfrStart or through the settings.Gershom
I would think that the flag is a general setting for the flight recorder engine, which is already started when you call the MBean to start a particular recording, so you would still need the flag on the command line.Butane
For JDK 9 we're looking at being able to configure the max stack depth at runtime, either as part of either the recording configuration or the template.Romany

© 2022 - 2024 — McMap. All rights reserved.