JProfiler HelpDownload

Support For JDK Flight Recorder (JFR)


JDK Flight Recorder (JFR) is a structured logging tool that records a broad range of system-level events. Similar to the black box of an aircraft that continuously records flight data for use in incident investigations, JFR continuously records a stream of events in the JVM for use in diagnosing problems. The advantage of this approach is that it captures chronologically detailed information about the system leading up to an incident. JFR is designed to have a minimal impact on performance, and to be safe to run in production environments over extended periods of time.

Starting with Java 17, JFR is also one of JProfiler's data sources. In addition to the native agent that uses the profiling interface of the JVM, there are high-level systems in the JVM that are of interest in a profiling context. One is the MBean system that provides data for some telemetries in JProfiler, and the other is JFR that is used for the garbage collector probe. For that purpose, you do not interact with JFR, but JProfiler handles JFR event streaming transparently.

JFR integration in JProfiler

JProfiler fully integrates JFR recording, so you can easily capture data from running JVMs on the local machine or on remote machines where JFR recording was not configured.

When you open a JFR snapshot in the JProfiler UI, the available views and sections are different from a regular profiling session. The centerpiece of the UI is the event browser. All other views that are available for JFR views are explained in a separate chapter.

As you work with event types, while setting filters and viewing analyses, JProfiler will occasionally have to rescan the JFR snapshot file. JFR snapshot files are potentially huge, and it is not viable to hold all data in memory or to calculate all analyses upfront. Because of this, it is not recommended to open JFR snapshots from network drives.

When opening very large JFR snapshots, you can speed up snapshot processing and reduce memory usage by clicking on the "Customize analysis" check box in the file chooser and excluding the event categories that are not required for your analysis. The available event categories cover single probes and view sections. Event types for CPU views, memory views and for the telemetry views are not optional and have to be loaded.

For example, if you are only interested in CPU data, you can exclude all probes and the event browser. JProfiler aims to be the fastest JFR viewer and opens typical JFR snapshots quickly, but JFR recordings are potentially unbounded and you could be confronted with a snapshot that is tens of gigabytes in size where the opening speed may become an issue.

Stack traces in JFR snapshots

One important feature of JFR is the ability to log the entire stack trace for a certain event type in an efficient way. For such events types, you can toggle stack trace recording in the JFR settings. Many JVM application event types, especially the ones that are concerned with threads, have stack trace recording enabled by default.

JFR only collects stack traces up to a fixed depth, so long stack traces are truncated. Truncated traces are not suitable for building an understandable call tree, so these traces are shown below a specially marked node. With the

-XX:FlightRecorderOptions=stackdepth=<nnnn>

VM parameter, you can increase the size of the collected traces in JFR and get rid of truncated traces for your application.