I checked Java Flight Recorder (JFR)

Nowadays, what is Java Flight Recorde?

Java Flight Recorde (JFR) is, in a nutshell, a Java profiler. A module included in Java SE Advanced that requires a commercial license (for a fee) to be used in a production environment, but can be used free of charge during development.

JFR is built into the Java SE execution environment from Java7, It (apparently) efficiently records the data already collected in the Java runtime environment! It will also be included in the latest Java 9.

Well-known Java profilers other than JFR jvmmonitor, JProfiler, JProbe, a while ago, there is TPTP (Test & Performance Tools Platform) of Eclipse, but There is a charge, or development is stopped and it can no longer be used.

When do you use JFR? What can i do?

JFR suddenly crashes the machine when the application is running all the time! Or, this application has a bad response! It is a tool to use when you need to investigate memory leaks or improve the performance of your application.

The functions of JFR are as follows.

-** Profiling ** JFR continually stores large amounts of data about operating systems. This profiling information includes the following information and the like. --Java application information: exceptions, threads, file I / O, network I / O, etc. --JavaVM information: memory allocation, class loading, JIT, GC, method sampling --OS information: Memory and CPU usage information

-** Black Box Analysis ** JFR continuously stores information in a circular buffer, so if you access this information when an anomaly is detected, you can find out the cause.

How to use JFR

Used in Java command options

To use JFR from Java commands, specify the following options.

-"-XX: + Unlock Commercial Features": Unlock commercial features -"-XX: + FlightRecorder": Enable JFR --"-XX: StartFlightRecording": Start recording JFR

How to run the MyApp application and immediately start recording for 60 seconds and save it to a file named recording.jfr

$ java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=60s,filename=/tmp/recording.jfr MyApp



 See below for the parameters of "-XX: Start Flight Recording".
[https://docs.oracle.com/cd/E22646_01/doc.40/b61441/optionxx.htm#BABIEFBA](https://docs.oracle.com/cd/E22646_01/doc.40/b61441/optionxx.htm#BABIEFBA)

## Used with jcmd command
 The jcmd command is a command that allows you to profile a running Java process.
 To use JFR from the jcmd command,
 The "-XX: + UnlockCommercialFeatures" and "-XX: + FlightRecorder" options must be specified when starting the Java application.

 How to start recording for 60 seconds in a running Java process with a process identifier of 5368 and save it to a file named recording.jfr


#### **`$ jcmd 5368 JFR.start duration=60s filename=/tmp/recording.jfr`**

Where it changes with Java9!

It seems that Java 9 will make the JFR UI significantly different and easier to use. The JFR API will be supported to allow recorder control and custom event generation.

Summary

The performance of an application is greatly affected by how it is made, and I think that many of the factors that cause performance degradation are problems of how it is made (creator).

If you can use profiling tools to find and fix bottlenecks, You can dramatically improve the performance of your application!

Let's make effective use of profiling tools to develop better things.

JFR is available free of charge during ** development! ** **

Recommended Posts

I checked Java Flight Recorder (JFR)
Troubleshooting with Java Flight Recorder
Check heap usage with Java Flight Recorder
How to record JFR (Java Flight Recorder) and output a dump file
OpenJDK 11 Flight Recorder
I checked this
I first touched Java ②
I first touched Java ③
I first touched Java ④
I first touched Java
I checked Zenzenzense, not Zenzenzense
Run analysis with OpenJDK11 Java Flight Recorder + Google Kubernetes Engine
What I researched about Java 8
I started Java Gold (Chapter 1-1)
What I researched about Java 6
I made roulette in Java.
What I researched about Java 9
I investigated Java primitive types
I took Java SE8 Gold.
I tried Drools (Java, InputStream)
Circuit Breaker Pattern I checked
What I researched about Java 7
I tried using Java REPL
[Java] I implemented the combination.
Java concurrency I don't understand
I studied the constructor (java)
I tried metaprogramming in Java
What I researched about Java 5