Red Hat OpenJDK DebugNonSafepoints Flag usage on Java Flight Recorder

Solution Unverified - Updated

Environment

  • OpenJDK 8
  • OpenJDK 11

Issue

  • What does the flag DebugNonSafepoints do?
  • How to start JFR with the flag?

Resolution

The flag DebugNonSafepoints adds sampling information to the JFR recording mainly by because the compiler will generate the necessary metadata for the parts of the code not at safe points, instead of just safe points.
Usage must be done combined with UnlockDiagnosticVMOptions, example:

$JAVA_HOME/bin/java -XX:+UnlockCommercialFeatures -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:StartFlightRecording=duration=1m,delay=30s,filename=test.jfr -jar example.jar

Example

Below are respective the profiling with and without the DebugNonSafepoints flag:

DebugNonSafepoints usage:
Non Flag usage

Not using DebugNonSafepoints:
Flag usage

Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.