SlideShare a Scribd company logo
Miroslav Wengner
Flight Recorder
meets Java
Safe Harbour Statement
All what you will hear can be di
ff
erent, this presentation is for
motivational purposes …
Miroslav Wengner
• Husband, Father, Software Engineer, Technology Enthusiast
• JCP: Executive Committee Board Member
• OpenJDK Committer , Java Mission Control Project, Open-Source
• Co-Author of Robo4J Project (Duke Award)
• Java Champion, JavaOne RockStar, Blogger
• Principal Engineer at OpenValue
• Group Of Talented and Motivated Individuals
• Netherlands, Germany, Switzerland, Austria…
• Fun, Development, Trainings, Migration and
more…
Application
Crash
No Relevant
Information
Adding a
Logging
Performance
Penalties
Removing
Logging
Agenda
• History in nutshell
• JMC and Flight Recorder in bullet points
• JFR under the hood
• JFR in Action and Examples
• Power of Data Visualisation
• What about JDK improvements and upcoming features?
• Q/A
History in nutshell
• 1998 Appeal Virtual Machines (AVM) - JRockit JVM
• 2002 AVM acquired by BEA
• 2008 acquired by Oracle
• 2012 JDK 7u4 update: Oracle integrated JFR into the HotSpot
• 2017 JDK 9 : Public APIs for creating and consuming data
• 2018 JDK 11: JMC/JFR announced to be fully Open-Sourced
JFR in bullets
• Part of Java Mission Control project
• Java Flight Recorder is an event based tracing framework
• Build directly into the Java Virtual Machine
• Provides access to all internal events
• Allows to create custom events
• Tries to achieve a goal 1% overhead
JFR meets Java Platform
• Compiled to byte-code
• Usage of JIT Compiler
• Byte code optimisation
• module, package: jdk.jfr
Profiling with JFR
• Observability allows to measure a system based on provided data metrics
(local, on-prem or cloud)
• each application may have di
ff
erent telemetry, di
ff
erent assumptions
• hardware, container, end-points, libraries….
• Monitoring -> keeping yes on sampled data
• Pro
fi
ling -> recording and analysing “real” data
https://www.hippopx.com/en/camera-security-monitoring-big-brother-control-surveillance-camera-video-surveillance-81117
Common Usage of JFR
• Micros-Services, Distributes and Stand-Alone applications
• helps in root-cause analysis
• application understanding, bottlenecks
• solution correctes
• testing
• monitoring
Let’s split
More Pods there…
Java Mission Control Project
Current release 8.3
Release Milestone Date
========== =========== ==========
8.2.0 GA 2022-01-19
8.2.1 GA 2022-06-16
8.3 EA 2022-10-11
8.1 : New Allocation Events for JDK 16,
• JMC Agent, JMC Agent Plugin
• Performance Improvements : Perser, Rules
8.2: Minor release
• JFR: Heat-Map View, WebSocket-API
8.3: Minor release
• JMC Core: Parser improvements
• JFR: Dependency view, Graph Pruning, JFR: Selectable attributes,
• Agent: bug
fi
xing
Java Mission Control Project
Current release 8.3
Dependency View
Graph pruning View
Flameview Selectable Attributes
Java Flight Recorder
under the hood
Java Event API
JVM Events
Thread Local
Buffers
Events
Global Bu
ff
ers
Repository
per 1s
JFR Event Streaming (JEP 349): Continual Monitoring
JFR under the hood: Event - fundamental element
• Import “jdk.jfr.Event”
• Basic Element that caries valuable information
EventID:
Timestamp : when event was taken
Duration: not always
Thread ID: Thread where event has occurred
StackTrace ID: It’s optional referst to the StackTrace, default depth 64
Payload: custom information
Import jdk.jfr.Event;
public class SampleEvent extends Event {
//internal logic
String message;
}
…
void someAdvanceLogic() {
SampleEvent e = new SampleEvent();
e.message = “Important Information”;
e.begin();
// advanced logic
e.end();
e.commit();
}
…
JFR under the hood: Event
JFR under the hood: : Tuning up an Event
Annotations: https://docs.oracle.com/en/java/javase/19/docs/api/jdk.jfr/jdk/jfr/class-use/MetadataDe
fi
nition.html
Annotation Description Default
@Name
Automatically Set, Recommended pattern: org.com…
Event
Full path with Name:
openvalue.SampleEvent
@Label Short descriptive information
@Category Category is present to the user
@Threshold
Default min duration fo the event to be included in the
recording
0ns
@StackTrace Include a stack-trace to the event TRUE
@Enabled Is Event enabled by default con
fi
guration
JFR under the hood: : Tuning up an Event
import jdk.jfr.Event
import jdk.jfr.Label
import jdk.jdf.Name
@Name(“com.openvalue.events.SampleEvent”)
@Label(“Sample Event”)
class SampleEvent extends Event {
@Label(“Message”)
String name;
@Label(“Value”)
int value;
}
Annotations: https://docs.oracle.com/en/java/javase/19/docs/api/jdk.jfr/jdk/jfr/class-use/MetadataDe
fi
nition.html
JFR under the hood: Performance
• Usage of Thread Local Bu
ff
ers
• Java Platform Optimisation
• Methods: INLINING, CODE ELIMINATION, SCALARIZATION
• What happens when event is enabled / disabled
-XX:StartFlightRecording=filename=<RECORDING_FILE>.jfr,dumponexit=true,settings=profile
void someAdvanceLogic() {
SampleEvent e = new SampleEvent();
e.message = “Important Information”;
e.begin();
// advanced logic
e.commit();
}
void commit() {
// IF it’s not enabled -> NOT INTERESTING
if(isEnabled()){
//now() reads CPU clock register, cheap check
long duration = now() - startTime;
if(duration > THRESHOLD) {
if (shouldCommit()) {
// Cheap - Thread local writes
actuallyCommit();
}
}
}
Mikeal Vidstedt presented quite neat pseudo-code that helps to understand to the commit()
JFR under the hood: Event in Action
void someAdvanceLogic(){
// allocating event
SampleEvent e = new SampleEvent();
e.begin(); -> INLINING => e.startTime = now(); -> e.startTime = <JVM intrinsic>
// advanced logic
// timestamp, likewise INLINING, implicit end()
e.commit();
// JFR ENABLED STATE
if(e.isEnabled()){
// perform additional checks and maybe actuallyCommit()
}
}
JFR under the hood: Enabled
JFR under the hood: Disabled - part 1
void someAdvanceLogic() {
SampleEvent e = new SampleEvent();
// INLINING from the previous slide
e.startTime = <JVM intrinsic>;
// advanced logic
//INLINING
if(false) { // result e.isEnabled()
//perform additional checks
//CODE ELIMINATION -> will be removed
}
}
JFR under the hood: Disabled - part 2
void someAdvanceLogic() {
SampleEvent e = new SampleEvent(); // SCALARIZATION -> REMOVAL
e.begin()
1. initial state: e.begin();
2. INLINING => e.startTime = <JVM intrinsic>;
3. INLINING => long startTime = <JVM intrisic>;
4. CODE ELIMINATION => long startTime = <JVM intrisic>; REMOVAL
//business logic
}
JFR under the hood: Disabled - part 3
void someAdvanceLogic() {
//business logic
}
JFR: Start Recording
# Starting a recording
$ java -XX:StartFlightRecording …
# Starting Recording and Storing into the file
$ java -XX:StartFlightRecording=filename=<FILE_NAME>.jfr
# Starting Recording and dump on exit
$ java -XX:StartFlightRecording=filename=<FILE_NAME>.jfr,dumponexit-true,settings=profile
# Using jcmd command via PID to start recording
$ jcmd <PID> JFR.start duration=30s filename=hotmethods_jcmd.jfr
JFR: Data Visualisation
• Command line tool avaliable from JDK 11 => jfr
$jfr summary <JFR_file>
$jfr print —json <JFR_FILE>
• JFR GUI. (DEMO)
• Automated analysis
• Java Application => Thread, Memory, etc.
• Event Browser
DEMO: Hot-Methods
DEMO: Hot-Methods - Events streaming
DEMO: Garbage-Collection
DEMO: Latency
DEMO: Java Platform Module Latency
var threadPerTaskExecutor = Executors.newThreadPerTaskExecutor(threadFactory);
var executor = Executors.newVirtualThreadPerTaskExecutor();
threadPerTaskExecutor.execute(() -> {
while (active.get()){
executor.submit(new ComputableTask(counter));
}
})
•
JFR: How to Get
• Clone: https://github.com/openjdk/jmc. => script build.sh
• AdoptOpenJDK: http://adoptopenjdk.net/jmc
• Azul: https://www.azul.com/products/zulu-mission-control
• RedHat: distributes as RPMs in Fedora and RHEL
• Oracle: https://www.oracle.com/java/technologies/jdk-mission-control.html
JMC-JVM-LANG Tutorial: https://github.com/mirage22/jmc-jvm-lang-tutorial
JFR-Tutorial: https://github.com/thegreystone/jmc-tutorial
Q / A
Thank YOU !
twitter: @miragemiko
gitlab:@mirage22
DEMOS: https://github.com/mirage22/jmc-jvm-lang-tutorial
References:
• Project Amber: https://openjdk.org/projects/amber/
• Project Loom: https://openjdk.org/projects/loom/
• JFR Project: https://github.com/openjdk/jmc
• OpenJDK: https://openjdk.org/
• JEP-349 JFR Event Steaming: https://openjdk.org/jeps/349
• foojay.io: https://foojay.io/today/author/miro-wengner/
• OpenValue Blog: https://openvalue.blog/
Book In Progress: Practical Design Patterns for Java Developers [PACKT]

More Related Content

Similar to ASML_FlightRecorderMeetsJava.pdf (20)

PDF
Using Java Mission Control & Java Flight Recorder
Isuru Perera
 
PDF
Java mission control and java flight recorder
Wolfgang Weigend
 
PPTX
Diagnosing HotSpot JVM Memory Leaks with JFR and JMC
Mushfekur Rahman
 
PDF
使ってみよう!JDK Flight Recorder
Yoshiro Tokumasu
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PPTX
Java Mission Control: Java Flight Recorder Deep Dive
Marcus Hirt
 
PDF
Continuous Performance Regression Testing with JfrUnit
ScyllaDB
 
PPTX
JFR Java Flight REcorder CON10912_UsingJFR.pptx
ssuser75e305
 
PDF
Using Java Flight Recorder
Marcus Hirt
 
PPTX
Getting Started with JDK Mission Control
Marcus Hirt
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PDF
A short Intro. to Java Mission Control
Haim Yadid
 
PDF
JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]
David Buck
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PDF
Tools in action jdk mission control and flight recorder
Jean-Philippe BEMPEL
 
PDF
Diagnosing Your Application on the JVM
Staffan Larsen
 
PDF
Java Profiling Future
Jaroslav Bachorik
 
PPT
Jpf model checking
thought444
 
PDF
ContextualContinuous Profilng
Jaroslav Bachorik
 
PDF
Head toward Java 14 and Java 15
Yuji Kubota
 
Using Java Mission Control & Java Flight Recorder
Isuru Perera
 
Java mission control and java flight recorder
Wolfgang Weigend
 
Diagnosing HotSpot JVM Memory Leaks with JFR and JMC
Mushfekur Rahman
 
使ってみよう!JDK Flight Recorder
Yoshiro Tokumasu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Java Mission Control: Java Flight Recorder Deep Dive
Marcus Hirt
 
Continuous Performance Regression Testing with JfrUnit
ScyllaDB
 
JFR Java Flight REcorder CON10912_UsingJFR.pptx
ssuser75e305
 
Using Java Flight Recorder
Marcus Hirt
 
Getting Started with JDK Mission Control
Marcus Hirt
 
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
A short Intro. to Java Mission Control
Haim Yadid
 
JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]
David Buck
 
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Tools in action jdk mission control and flight recorder
Jean-Philippe BEMPEL
 
Diagnosing Your Application on the JVM
Staffan Larsen
 
Java Profiling Future
Jaroslav Bachorik
 
Jpf model checking
thought444
 
ContextualContinuous Profilng
Jaroslav Bachorik
 
Head toward Java 14 and Java 15
Yuji Kubota
 

More from Miro Wengner (10)

PDF
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
PDF
Boost delivery stream with code discipline engineering
Miro Wengner
 
PDF
[meetup] Mastering Java enhancements like a Pro: practical design patterns an...
Miro Wengner
 
PDF
New Java features: Simplified Design Patterns[LIT3826]
Miro Wengner
 
PDF
Plug Hardware and Play Java
Miro Wengner
 
PDF
From Concept to Robotic Overlord with Robo4J
Miro Wengner
 
PDF
JavaOne 2016 :: Bringing Robot online with Robo4j Framework
Miro Wengner
 
PDF
JavaOne presentation - building steps :: Number42 is alive
Miro Wengner
 
PDF
The Robot under dictate of the LegoMindStorm Java Concurrency API
Miro Wengner
 
PDF
How RaspberryPi workers building GraphDatabase
Miro Wengner
 
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Boost delivery stream with code discipline engineering
Miro Wengner
 
[meetup] Mastering Java enhancements like a Pro: practical design patterns an...
Miro Wengner
 
New Java features: Simplified Design Patterns[LIT3826]
Miro Wengner
 
Plug Hardware and Play Java
Miro Wengner
 
From Concept to Robotic Overlord with Robo4J
Miro Wengner
 
JavaOne 2016 :: Bringing Robot online with Robo4j Framework
Miro Wengner
 
JavaOne presentation - building steps :: Number42 is alive
Miro Wengner
 
The Robot under dictate of the LegoMindStorm Java Concurrency API
Miro Wengner
 
How RaspberryPi workers building GraphDatabase
Miro Wengner
 
Ad

Recently uploaded (20)

PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Ad

ASML_FlightRecorderMeetsJava.pdf

  • 2. Safe Harbour Statement All what you will hear can be di ff erent, this presentation is for motivational purposes …
  • 3. Miroslav Wengner • Husband, Father, Software Engineer, Technology Enthusiast • JCP: Executive Committee Board Member • OpenJDK Committer , Java Mission Control Project, Open-Source • Co-Author of Robo4J Project (Duke Award) • Java Champion, JavaOne RockStar, Blogger • Principal Engineer at OpenValue
  • 4. • Group Of Talented and Motivated Individuals • Netherlands, Germany, Switzerland, Austria… • Fun, Development, Trainings, Migration and more…
  • 6. Agenda • History in nutshell • JMC and Flight Recorder in bullet points • JFR under the hood • JFR in Action and Examples • Power of Data Visualisation • What about JDK improvements and upcoming features? • Q/A
  • 7. History in nutshell • 1998 Appeal Virtual Machines (AVM) - JRockit JVM • 2002 AVM acquired by BEA • 2008 acquired by Oracle • 2012 JDK 7u4 update: Oracle integrated JFR into the HotSpot • 2017 JDK 9 : Public APIs for creating and consuming data • 2018 JDK 11: JMC/JFR announced to be fully Open-Sourced
  • 8. JFR in bullets • Part of Java Mission Control project • Java Flight Recorder is an event based tracing framework • Build directly into the Java Virtual Machine • Provides access to all internal events • Allows to create custom events • Tries to achieve a goal 1% overhead
  • 9. JFR meets Java Platform • Compiled to byte-code • Usage of JIT Compiler • Byte code optimisation • module, package: jdk.jfr
  • 10. Profiling with JFR • Observability allows to measure a system based on provided data metrics (local, on-prem or cloud) • each application may have di ff erent telemetry, di ff erent assumptions • hardware, container, end-points, libraries…. • Monitoring -> keeping yes on sampled data • Pro fi ling -> recording and analysing “real” data https://www.hippopx.com/en/camera-security-monitoring-big-brother-control-surveillance-camera-video-surveillance-81117
  • 11. Common Usage of JFR • Micros-Services, Distributes and Stand-Alone applications • helps in root-cause analysis • application understanding, bottlenecks • solution correctes • testing • monitoring Let’s split More Pods there…
  • 12. Java Mission Control Project Current release 8.3 Release Milestone Date ========== =========== ========== 8.2.0 GA 2022-01-19 8.2.1 GA 2022-06-16 8.3 EA 2022-10-11 8.1 : New Allocation Events for JDK 16, • JMC Agent, JMC Agent Plugin • Performance Improvements : Perser, Rules 8.2: Minor release • JFR: Heat-Map View, WebSocket-API 8.3: Minor release • JMC Core: Parser improvements • JFR: Dependency view, Graph Pruning, JFR: Selectable attributes, • Agent: bug fi xing
  • 13. Java Mission Control Project Current release 8.3 Dependency View Graph pruning View Flameview Selectable Attributes
  • 14. Java Flight Recorder under the hood Java Event API JVM Events Thread Local Buffers Events Global Bu ff ers Repository per 1s JFR Event Streaming (JEP 349): Continual Monitoring
  • 15. JFR under the hood: Event - fundamental element • Import “jdk.jfr.Event” • Basic Element that caries valuable information EventID: Timestamp : when event was taken Duration: not always Thread ID: Thread where event has occurred StackTrace ID: It’s optional referst to the StackTrace, default depth 64 Payload: custom information
  • 16. Import jdk.jfr.Event; public class SampleEvent extends Event { //internal logic String message; } … void someAdvanceLogic() { SampleEvent e = new SampleEvent(); e.message = “Important Information”; e.begin(); // advanced logic e.end(); e.commit(); } … JFR under the hood: Event
  • 17. JFR under the hood: : Tuning up an Event Annotations: https://docs.oracle.com/en/java/javase/19/docs/api/jdk.jfr/jdk/jfr/class-use/MetadataDe fi nition.html Annotation Description Default @Name Automatically Set, Recommended pattern: org.com… Event Full path with Name: openvalue.SampleEvent @Label Short descriptive information @Category Category is present to the user @Threshold Default min duration fo the event to be included in the recording 0ns @StackTrace Include a stack-trace to the event TRUE @Enabled Is Event enabled by default con fi guration
  • 18. JFR under the hood: : Tuning up an Event import jdk.jfr.Event import jdk.jfr.Label import jdk.jdf.Name @Name(“com.openvalue.events.SampleEvent”) @Label(“Sample Event”) class SampleEvent extends Event { @Label(“Message”) String name; @Label(“Value”) int value; } Annotations: https://docs.oracle.com/en/java/javase/19/docs/api/jdk.jfr/jdk/jfr/class-use/MetadataDe fi nition.html
  • 19. JFR under the hood: Performance • Usage of Thread Local Bu ff ers • Java Platform Optimisation • Methods: INLINING, CODE ELIMINATION, SCALARIZATION • What happens when event is enabled / disabled -XX:StartFlightRecording=filename=<RECORDING_FILE>.jfr,dumponexit=true,settings=profile
  • 20. void someAdvanceLogic() { SampleEvent e = new SampleEvent(); e.message = “Important Information”; e.begin(); // advanced logic e.commit(); } void commit() { // IF it’s not enabled -> NOT INTERESTING if(isEnabled()){ //now() reads CPU clock register, cheap check long duration = now() - startTime; if(duration > THRESHOLD) { if (shouldCommit()) { // Cheap - Thread local writes actuallyCommit(); } } } Mikeal Vidstedt presented quite neat pseudo-code that helps to understand to the commit() JFR under the hood: Event in Action
  • 21. void someAdvanceLogic(){ // allocating event SampleEvent e = new SampleEvent(); e.begin(); -> INLINING => e.startTime = now(); -> e.startTime = <JVM intrinsic> // advanced logic // timestamp, likewise INLINING, implicit end() e.commit(); // JFR ENABLED STATE if(e.isEnabled()){ // perform additional checks and maybe actuallyCommit() } } JFR under the hood: Enabled
  • 22. JFR under the hood: Disabled - part 1 void someAdvanceLogic() { SampleEvent e = new SampleEvent(); // INLINING from the previous slide e.startTime = <JVM intrinsic>; // advanced logic //INLINING if(false) { // result e.isEnabled() //perform additional checks //CODE ELIMINATION -> will be removed } }
  • 23. JFR under the hood: Disabled - part 2 void someAdvanceLogic() { SampleEvent e = new SampleEvent(); // SCALARIZATION -> REMOVAL e.begin() 1. initial state: e.begin(); 2. INLINING => e.startTime = <JVM intrinsic>; 3. INLINING => long startTime = <JVM intrisic>; 4. CODE ELIMINATION => long startTime = <JVM intrisic>; REMOVAL //business logic }
  • 24. JFR under the hood: Disabled - part 3 void someAdvanceLogic() { //business logic }
  • 25. JFR: Start Recording # Starting a recording $ java -XX:StartFlightRecording … # Starting Recording and Storing into the file $ java -XX:StartFlightRecording=filename=<FILE_NAME>.jfr # Starting Recording and dump on exit $ java -XX:StartFlightRecording=filename=<FILE_NAME>.jfr,dumponexit-true,settings=profile # Using jcmd command via PID to start recording $ jcmd <PID> JFR.start duration=30s filename=hotmethods_jcmd.jfr
  • 26. JFR: Data Visualisation • Command line tool avaliable from JDK 11 => jfr $jfr summary <JFR_file> $jfr print —json <JFR_FILE> • JFR GUI. (DEMO) • Automated analysis • Java Application => Thread, Memory, etc. • Event Browser
  • 28. DEMO: Hot-Methods - Events streaming
  • 31. DEMO: Java Platform Module Latency var threadPerTaskExecutor = Executors.newThreadPerTaskExecutor(threadFactory); var executor = Executors.newVirtualThreadPerTaskExecutor(); threadPerTaskExecutor.execute(() -> { while (active.get()){ executor.submit(new ComputableTask(counter)); } }) •
  • 32. JFR: How to Get • Clone: https://github.com/openjdk/jmc. => script build.sh • AdoptOpenJDK: http://adoptopenjdk.net/jmc • Azul: https://www.azul.com/products/zulu-mission-control • RedHat: distributes as RPMs in Fedora and RHEL • Oracle: https://www.oracle.com/java/technologies/jdk-mission-control.html JMC-JVM-LANG Tutorial: https://github.com/mirage22/jmc-jvm-lang-tutorial JFR-Tutorial: https://github.com/thegreystone/jmc-tutorial
  • 33. Q / A Thank YOU ! twitter: @miragemiko gitlab:@mirage22 DEMOS: https://github.com/mirage22/jmc-jvm-lang-tutorial
  • 34. References: • Project Amber: https://openjdk.org/projects/amber/ • Project Loom: https://openjdk.org/projects/loom/ • JFR Project: https://github.com/openjdk/jmc • OpenJDK: https://openjdk.org/ • JEP-349 JFR Event Steaming: https://openjdk.org/jeps/349 • foojay.io: https://foojay.io/today/author/miro-wengner/ • OpenValue Blog: https://openvalue.blog/ Book In Progress: Practical Design Patterns for Java Developers [PACKT]