Java Flight Recorder (JFR)¶
About
The jcmd utility is the traditional application to inquire diagnostic information from applications running on the JVM, also including the Java Flight Recorder (JFR).
Details
The Java Flight Recorder (JFR) is a profiling and event collection framework to gather detailed low-level information about how the Java Virtual Machine (JVM) and Java applications are behaving during execution.
Flight recordings can be started when the application is started or while the application is running. The data is recorded as time-stamped data points called events.
JFR is part of the JDK distribution, and it is integrated into the JVM.
- Events:
JFR collects events that occur in the JVM when the Java application runs. The events are related to the state of the JVM itself or the state of the program. An event has a name, a timestamp, and additional information, like thread information, execution stack, and state of the heap.
- Recording Types:
A time fixed recording, also known as a profiling recording, runs for a set amount of time, and then stops. A continuous recording is a recording that is always on and saves, for example, the last six hours of data into a circular buffer, discarding old data when the buffer fills up.
- Performance:
The events that JFR collects contain a huge amount of data. For this reason, JFR is designed to affect the performance of a running application as little as possible.
JFR saves data about the events into a single output file. Because disk I/O operations are expensive, JFR uses various buffers to store collected data before flushing blocks of data to disk.
Synopsis¶
jcmd 1 JFR.start duration=60s filename=/data/recording1.jfr
jcmd 1 JFR.start duration=300s filename=/data/recording2.jfr settings=profile
Learn¶
Fundamentals
This tutorial examines Java Flight Recorder, its concepts, its basic commands, and how to use it.
A concise example how to generate a JFR file using the jcmd command.
The official documentation about JFR outlines its advantages, its event types grouped by recording templates, and its types of recordings. It also describes in detail how to produce flight recordings, what’s inside, and how to analyze them.
CrateDB
Learn why the standard way to run jcmd
does not work when running CrateDB
inside a container, for example when using Docker, and how to resolve that
problem.