Giter Club home page Giter Club logo

flight_recorder_demo's Introduction

Java Flight Recorder & Java Mission Control demo app

Requirements for this demo/tutorial
Please note that JFR and JMC are only free to use in Open JDK, in Oracle JDK these are paid commercial features. Please check your can/should use it on your JDK.

What is Java Flight Recorder (JFR)

  • JFR is part of JDK it produces detailed recordings about the HotSpot JVM, and the application it is running.
  • It is an event recorder built into the Java virtual machine, it can be thought of as the software equivalent of a Data Flight Recorder (Black Box) in a commercial aircraft.
  • Recorded events can be analyzed offline using the Java Mission Control tool.
  • Recorded data includes profiling of methods, locks and allocations, as well as garbage collection statistics, optimization decisions, event latencies and more.
JFR offers extremely low overhead of about 1% Therefore it can be used at production environments!
  • In 2018 Java Flight Recorder was open sourced and released as part of OpenJDK 11, at later date it was backported into OpenJDK 8 from update 262.

how to run JFR:

  • by adding JVM options to your java process
  • by execution of jcmd instruction to your JVM process

What is Java Mission Control (JMC)

  • JDK Mission Control is an open source tools suite for the Java virtual machine.
  • The tools help to find problems in, and optimizing, programs running on the JVM in production.
  • Support OpenJDK from version 8 from update 262.

what can you do with JMC:

  • connect to the running JVM process via JMX and do current quick analysis of CPU, Memory, process spec, GC cycles. This looks similar to Visual VM
  • open Flight recorder file generated by the JFR process
  • use JMC command to start flight recorder on given JVM process (Instruct JVM to start/stop JFR process).
  • use JMC plugins

How to enable JFR on your service by adding VM options:

  • on Open JDK8 (from update 262)

-XX:StartFlightRecording=settings=default,dumponexit=true,disk=true,maxsize=1MB,filename=testFlightRecord.jfr

This will start continuous recording of JFR events, with max size ever held of 1 MB it will output these recordings to testFlightRecord.jfr file upon exit, or upon receive of DUMP instruction from jcmd for example: jcmd <PID> JFR.dump name=1 setting=default will start JFR with default config profile, there are two profiles available (one can add more or modify existing ones) located in jdk-11.0.8.10-hotspot\lib\jfr

  • on Open JDK11 (the same command)

-XX:StartFlightRecording=settings=default,dumponexit=true,disk=true,maxsize=1MB,filename=testFlightRecord.jfr

How to enable/disable it by jcmd

$ jcmd <PID> JFR.start duration=10h filename=myrecording.jfr

or

$ jcmd <PID> JFR.stop

other commands:

   JFR.configure
   JFR.stop
   JFR.start
   JFR.dump
   JFR.check

Other ways to enable Java Flight Recorder

  • Intellij has build in Run with profiler
  • Java Mission Control(JMC) can start JFR recording (it is using jcmd in the background)

How to read and interpret JFR Data

to read data use Java Mission Control tool. Open it and point to the .jfr file.

What is coming next

from Java 14 streaming of the JFR events is available... JEP 349 Get a stream of high-volume data points about your running app. by Ben Evans

Reference

For further reference, please consider the following sections:

flight_recorder_demo's People

Contributors

wasylni avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.