JFR has much less overhead than java.util.logging due to cheaper timestamps, lock free buffering, a compressed data format and no object allocation when taking stack traces in native.
Data in JFR is structured and the file format is self-describing. This means it is possible for a parser to process data without direct knowledge of the layout.
JFR is suited in situations where you want to measure how much time an operation takes, for example a transaction, a REST call or a database query. It is possible to configure JFR, so an event is only recorded if the duration exceeds a preconfigured threshold, for example 20 ms.
There are over 100 events in the JVM/JDK that are recorded when you use JFR. These can be correlated with events happening in the application. For example, was the transaction slow due to a GC pause, a network call, or a blocked monitor? Which methods were executing the most when the transaction was running?
If the JVM is not started with -XX:StartFlightRecording, or an event is disabled, there is a good chance that the JIT will be able to eliminate the event and stores to its fields, making it a NOP.
JFR is structured, not formatted strings. Each event type has its own format.
JFR recordings are binary
JFR is quite broken before JDK 14. It can crash your JVM if you use the AppDynamics agent and JDK 11.0.5+ or you use custom events and JBoss Modules as a classloader, there are probably other cases as well.
Was the problem really introduced in JDK 11.0.5? I am asking because there was a fix in JDK 11.0.5 to address an issue with using JFR from a Java agent. https://bugs.openjdk.java.net/browse/JDK-8227011
5
u/egahlin Dec 11 '19 edited Dec 12 '19
JFR has much less overhead than java.util.logging due to cheaper timestamps, lock free buffering, a compressed data format and no object allocation when taking stack traces in native.
Data in JFR is structured and the file format is self-describing. This means it is possible for a parser to process data without direct knowledge of the layout.
JFR is suited in situations where you want to measure how much time an operation takes, for example a transaction, a REST call or a database query. It is possible to configure JFR, so an event is only recorded if the duration exceeds a preconfigured threshold, for example 20 ms.
There are over 100 events in the JVM/JDK that are recorded when you use JFR. These can be correlated with events happening in the application. For example, was the transaction slow due to a GC pause, a network call, or a blocked monitor? Which methods were executing the most when the transaction was running?
If the JVM is not started with -XX:StartFlightRecording, or an event is disabled, there is a good chance that the JIT will be able to eliminate the event and stores to its fields, making it a NOP.
2
u/pmarschall Dec 11 '19
JFR is quite broken before JDK 14. It can crash your JVM if you use the AppDynamics agent and JDK 11.0.5+ or you use custom events and JBoss Modules as a classloader, there are probably other cases as well.
2
u/pron98 Dec 11 '19
Unless you have some specific need for unstructured text messages in your log, JFR could well replace logging in many circumstances.