Flight Recorder in OpenJDK Erik Gahlin, Markus Grönlund Java Product Group Hotspot Runtime October 23, 2018
Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation.
What is Flight Recorder (JFR)? A system for recording events, analogous to the device in an aircraft. An event is a piece of data at a specific instant of time. Very low overhead, suitable for production environments. Execution history saved for the time period leading up to a problem. A useful tool for discovering latencies. Built-in events for JVM, JDK and OS. APIs for producing and consuming events. Frequently used by JVM engineers. Proven technology in JRockit and the Hotspot VM for almost 10 years.
Events in the JVM and JDK Garbage Collection Configuration, Pause times, Heap usage, Allocation requiring GC, Evacuations, Metaspace, Young Collection, Old Collection, G1, ZGC, Parallel... Runtime Safepoints, Class Loading, Threads, VM Operations, Biased Locking, Monitor inflation, Modules Compiler Compilations, Inlining Configuration System Properties, Command-line flags, Version string
Events in the JVM and JDK Java Application Exceptions and Errors Allocations Old Object (memory leaks) Thread Start, Thread End, Thread Park Socket I/O File I/O Monitor Wait, Monitor Blocked Operating System Environment Variables, Native Libraries, CPU Load and Context Switches, Network Utilization, Physical Memory, System Processes
Use cases Correctness Performance and scalability Troubleshooting We can add tests that use information in events to verify correctness. Performance and scalability Monitor and verify that correctness is completed within acceptable time intervals. Troubleshooting Investigate the execution and latency history persisted for time periods leading up to a problem. Save round-trips for data gathering and attach directly to bug report to get analysis underway faster. Understand real data in production environments Monitor patterns of real data, such as customer inputs.
OpenJDK – free and open source A commercial offering for many years. Contributed by Oracle to OpenJDK and open sourced in JDK 11. Free to use. Just as free to use as any GC or compiler in the VM. JDK Mission Control tool also open sourced in JDK 11.
Demo
How to describe your own events @Label, human-readable name, title cased @Description, a sentence describing the event/field @Category, a hierarchal categorization in the format of a human-readable path. @Name, identifying name, similar to fully qualified class name
Content Types
Duration event
Periodic event Useful for extracting the state of a system. Examples: CPU-load, command-line parameters, GC configuration
Configuration
Configuration File (.jfc) <configuration> <event name="com.company.product.HelloWorld"> <setting name="enabled">true</setting> <setting name="stackTrace">true</setting> <setting name="threshold">1 ms</setting> <setting name="period">1 s</setting> </event> </configuration> $> java -XX:StartFlightRecording:settings=my.jfc ... $> java -XX:StartFlightRecording:settings=default.jfc,my.jfc ...
Reading recording files Classes for reading recorded data. For example, RecordedEvent, RecordedObject, RecordedStackTrace, RecordedThread, RecordedMethod, RecordedClass Getters for extracting values from an event. For example, RecordedEvent::getDuration, RecordedEvent::getThread, RecordedEvent::getStackTrace
Some event practices
# {method} ‘fibonacci(I)I’ # Intel x86 syntax # -XX:LoopUnrollLimit=0
Definition
Deployment
Disabling
What about overhead?
# {method} 'getFibonacci(I)I' # Intel x86 syntax # -XX:LoopUnrollLimit=0
fibonacci(I)I getFibonacci(I)I
Future: Event Streaming Continuous consumption is important if you want to monitor an application, for instance update the chart of the CPU load once every second. To access JFR data today, a recording must be started, stopped and dumped to a seperate file This works well if you want data for a longer period of time, a minute or more, but not suited for monitoring due to overhead created by each new recording The intent is to provide users with an API so they can read directly from the disk repository as data is being recorded JEP draft: https://bugs.openjdk.java.net/browse/JDK-8184193
How to contribute Sign up on our mailing list: http://mail.openjdk.java.net/mailman/listinfo/hotspot-jfr-dev Look for small bugs and enhancements: https://bugs.openjdk.java.net/issues/?jql=Subcomponent%3Djfr Take a look at the source code: http://hg.openjdk.java.net/jdk/jdk/file/tip/src/jdk.jfr/ http://hg.openjdk.java.net/jdk/jdk/file/tip/src/jdk.management.jfr/ http://hg.openjdk.java.net/jdk/jdk/file/tip/src/hotspot/share/jfr Discuss changes on the mailing list Sign the Oracle Contributer Agreement and send out the patch for review
Questions?