SlideShare a Scribd company logo
Java and Performance

Tools and Toys
2021-02-25
Agend
a

• Methodolog
y

• Metric
s

• Profiling, Profiler
s

• Use Case
s

• Profile Viewer
s

• Profiling target
s

• Distributed profilin
g

• Other tool
s
www.luxoft.com
Starting Poin
t



“Use The Right Tool at the Right Place”
 

Anonymous plumber













Great Learning course at Lux Learning
:

В. Сонькин, Java Advanced II: Performance
Photo b y Simon Migaj @ unsplash.com
www.luxoft.com
Use the USE method
:

Resource List
:

๏ CPUs: sockets, cores, hardware threads (virtual CPUs
)

๏ Memory: capacit
y

๏ Network interface
s

๏ Storage devices: I/O, capacit
y

๏ Controllers: storage, network card
s

๏ Interconnects: CPUs, memory, I/O
http://www.brendangregg.com/usemethod.html
www.luxoft.com
Retrieving metrics
:



Ad-hoc, manual
:

๏ CPU: uptime, pidstat, top, vmstat, mpstat, etc
.

๏ IO: sar, iostat, iotop, etc
.

๏ Memory: free, top, et
c

๏ Errors: dmes
g

๏ …

๏ Swiss knife: dstat
http://www.brendangregg.com/Articles/Netflix_Linux_Perf_Analysis_60s.pdf
www.luxoft.com
Monitoring both

App and USE metrics:

Metrics reporting
:

๏ System: collectd, telegraf, etc
.

๏ Java: Micromete
r

Metrics aggregation
:

๏ Free: Prometheus/Grafana, etc
.

๏ Commercial: NewRelic, DataDog, CloudWatch, etc
.

NewRelic metrics Dashboard
https://micrometer.io
www.luxoft.com
Metrics: Use Cas
e

Alerts
:

๏ High system/irq/steal/… time
 

๏ High iowait time
 

๏ Low utilization high saturatio
n

๏ Spikes of any activit
y

๏ Error spike
s

๏ …
Metrics collected by Ganglia
???
www.luxoft.com
Flamegraph
s





Types
:

๏ CP
U

๏ Off-CP
U

๏ Memory, Allocatio
n

๏ Software/Hardware event
s

๏ Composite (Hot/Cold), Differential
http://www.brendangregg.com/flamegraphs.html
www.luxoft.com
Profiling and Profilers
:





Profiler types
:

๏ Instrumenting automate
d

๏ Instrumenting manua
l

๏ Samplin
g

๏ …
Survey by RebelLabs, RedHat Summit 2015, Lessons learned from the JBoss performance team
JavaDay UA 2017: Nitsan Wakart. Profilers Are Lying Hobbitses


Better Profiler types
:

๏ goo
d

๏ bad
www.luxoft.com
Async Profiler
:





Features
:

๏ No use of JVMTI GetAllStackTraces(), Safepoint Bias-fre
e

๏ Combines both worlds:

Java frames - AsynGetCallTrace(), internal HotSpot API

Native frames (user + kernel)- perf_event_open syscal
l

๏ Flexible events: CPU cycles, tracepoints, native/Java methods, 

PMU counter
s

๏ Flexible modes: CPU profiling, Off-CPU profiling, Allocation profilin
g

๏ Flexible output: bomb dump, “collapsed” (perf compatible), 

JFR, flamegraphs, call trees, conversion scripts
AP with Andrey Pangin: 4h-long (!!!) webinar: https://youtube.com/playlist?list=PLNCLTEx3B8h4Yo_WvKWdLvI9mj1XpTKBr
https://www.vecteezy.com/free-vector/the-end
www.luxoft.com
Async Profiler
:







Drawbacks
:

๏ No Windows suppor
t

๏ Allocation: same as JFR, slow path-only, 

TLAB bias, no JEP-331 support

Resolved in jvmti-tools/heapsampler project, YourKi
t

๏ No system-wide profilin
g

๏ No distributed profilin
g

๏ Tricky cases: e.g. cpu time/cycles vs physical time
https://github.com/apangin/codeone2019-java-profilin
g

Photo by Emiliano Vittoriosi @ unsplash.com
www.luxoft.com
Async Profiler
:



Configuration
:

๏ Allow collecting kernel frames:

$ sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'

$ sudo sh -c 'echo 0 >/proc/sys/kernel/kptr_restrict’

Running
:

๏ As JVM agent

-XX:+DebugNonSafepoint
s

๏ Attach to process

-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoint
s

๏ From Java application code



https://www.baeldung.com/java-async-profiler
Async Profiler help output
www.luxoft.com
Viewing Profiles
:



Profile Formats
:

๏ Summary (text
)

๏ Call Tre
e

๏ HTML Flamegrap
h

๏ SVG Flamegraph (v1.X, or requires flamegraph.pl script
)

๏ nflx (flamescope) 

java -cp build/converter.jar jfr2nflx myprofile.jfr out.nfl
x

Third-party Viewers
:

๏ IntelliJ IDEA Ultimate Editio
n

๏ SpeedScope (https://www.speedscope.app
)

๏ FlameScope (https://github.com/Netflix/flamescope)
SpeedScope
FlameScope
www.luxoft.com
Showtime: Example
1





CPU, Wall-clock:

Application structure revealed,



Hot paths of execution highlighted

in a very-very complex codebase.
Module A
Module B
Module C
www.luxoft.com
Example
2





CPU - Native frames
Business logic

Only this part is visible in VisualVM / JMC (!!!)
JVM went crazy with 600 threads
www.luxoft.com
Example
3





CPU, by Threads:

GC at work
Caption
Business logic
GC at work
www.luxoft.com
Example
4





CPU, Reversed
Caption
Business logic
GC at work
Structured
Chaotic
www.luxoft.com
Example
5





Allocation, Reversed
www.luxoft.com
What to profile
:





Production
:

๏ Enable on all or part of the nodes in pro
d

Loadtests
:

๏ Run nightly loadtests with profiling enable
d

๏ Correlate the loadtest results with metrics and perf. profiles
 

Benchmarks
:

๏ JMH integration in sbt-jmh by Konrad Malawski

https://github.com/ktoso/sbt-jmh

As simple as: -prof jfr / -prof async
Gatling Loadtest
NewRelic Dashboard
Performance Profile: JFR
Flamegraphs
www.luxoft.com
Distributed profilin
g





Collapsed flow
:

๏ Collect collapsed or JFR file
s

๏ Concatenate collected file
s

๏ Convert to desired format: svg, html, nflx (flamescope) 

Examples:

./flamegraph.pl --color java input.collapsed > out.svg

java -cp build/converter.jar jfr2nflx myprofile.jfr out.nfl
x

๏ Voila! View in favorite viewer
JMC 8.0
www.luxoft.com
Profiling: Other options





Commercial JVM profilers
:

๏ Amazon CodeGur
u

๏ Google Cloud Profile
r

๏ Opsian (by creator of honest-profiler
)

๏ DataDog continuous profile
r

๏ …
Photo by Fabian Blank @ unsplash.com
www.luxoft.com
Where to go next
?





Things you might want to look at
:

๏ PMU counters in Java

S. Kuksenko: Speed up you Java App with Hardware Counters
๏ TMAM Method: Top-down Micro-architecture Analysi
s

๏ Intel vTune Profile
r

๏ AMD µPro
f

๏ https://github.com/andikleen/pmu-tools, TopLe
v

๏ eBP
F

๏ …
Thank You!

More Related Content

What's hot (20)

PDF
Native Java with GraalVM
Sylvain Wallez
 
PDF
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Yunong Xiao
 
PDF
Rails Application Optimization Techniques & Tools
guest05c09d
 
PDF
jLove 2020 - Micronaut and graalvm: The power of AoT
Iván López Martín
 
ODP
Performance Optimization of Rails Applications
Serge Smetana
 
PDF
Bareon functional testing ci
Max Lobur
 
PPTX
Retrofitting Continuous Delivery
Alan Norton
 
PDF
CPAN Training
Pedro Figueiredo
 
PDF
Foreman - Advanced use cases - Timo Goebel
NETWAYS
 
PPTX
Nodejs Performance Debug
Rafael Gonzaga
 
PDF
美团点评技术沙龙08 - 分布式监控系统实践
美团点评技术团队
 
PPTX
Ruby/rails performance and profiling
Danny Guinther
 
PDF
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Bilgin Ibryam
 
PDF
High Fidelity Games: Real Examples, Best Practices ... | Oleksii Vasylenko
Jessica Tams
 
PDF
Windows IOCP vs Linux EPOLL Performance Comparison
Seungmo Koo
 
PDF
perlcc made easy or, how to make a CGI Moose app
cPanel
 
KEY
Scaling application servers for efficiency
Tomas Doran
 
PDF
Reverse Installing CPAN
brian d foy
 
PPTX
fsharp goodness for everyday work
Uladzimir Shchur
 
PDF
Whoops! I Rewrote It in Rust
ScyllaDB
 
Native Java with GraalVM
Sylvain Wallez
 
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Yunong Xiao
 
Rails Application Optimization Techniques & Tools
guest05c09d
 
jLove 2020 - Micronaut and graalvm: The power of AoT
Iván López Martín
 
Performance Optimization of Rails Applications
Serge Smetana
 
Bareon functional testing ci
Max Lobur
 
Retrofitting Continuous Delivery
Alan Norton
 
CPAN Training
Pedro Figueiredo
 
Foreman - Advanced use cases - Timo Goebel
NETWAYS
 
Nodejs Performance Debug
Rafael Gonzaga
 
美团点评技术沙龙08 - 分布式监控系统实践
美团点评技术团队
 
Ruby/rails performance and profiling
Danny Guinther
 
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Bilgin Ibryam
 
High Fidelity Games: Real Examples, Best Practices ... | Oleksii Vasylenko
Jessica Tams
 
Windows IOCP vs Linux EPOLL Performance Comparison
Seungmo Koo
 
perlcc made easy or, how to make a CGI Moose app
cPanel
 
Scaling application servers for efficiency
Tomas Doran
 
Reverse Installing CPAN
brian d foy
 
fsharp goodness for everyday work
Uladzimir Shchur
 
Whoops! I Rewrote It in Rust
ScyllaDB
 

Similar to Iurii Antykhovych "Java and performance tools and toys" (20)

PDF
Java Performance & Profiling
Isuru Perera
 
PDF
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
Red Hat Developers
 
PDF
Java in flames
Isuru Perera
 
PDF
Java Performance and Profiling
WSO2
 
PDF
Jvm profiling under the hood
RichardWarburton
 
PDF
The Art Of Performance Tuning - with presenter notes!
Jonathan Ross
 
PDF
Java Performance and Using Java Flight Recorder
Isuru Perera
 
PDF
Software Profiling: Java Performance, Profiling and Flamegraphs
Isuru Perera
 
PDF
Web Sphere Problem Determination Ext
Rohit Kelapure
 
PPTX
Java performance tuning
Jerry Kurian
 
PPTX
DIY Java Profiling
Roman Elizarov
 
PDF
ContextualContinuous Profilng
Jaroslav Bachorik
 
PDF
Java Profiling Future
Jaroslav Bachorik
 
PDF
JavaOne 2015 Java Mixed-Mode Flame Graphs
Brendan Gregg
 
PDF
Java black box profiling JUG.EKB 2016
aragozin
 
PDF
Introduction to Java Profiling
Jerry Yoakum
 
PDF
Using Flame Graphs
Isuru Perera
 
PPTX
Tuning Java Servers
Srinath Perera
 
PDF
Software Profiling: Understanding Java Performance and how to profile in Java
Isuru Perera
 
PDF
Impact2014: Introduction to the IBM Java Tools
Chris Bailey
 
Java Performance & Profiling
Isuru Perera
 
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
Red Hat Developers
 
Java in flames
Isuru Perera
 
Java Performance and Profiling
WSO2
 
Jvm profiling under the hood
RichardWarburton
 
The Art Of Performance Tuning - with presenter notes!
Jonathan Ross
 
Java Performance and Using Java Flight Recorder
Isuru Perera
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Isuru Perera
 
Web Sphere Problem Determination Ext
Rohit Kelapure
 
Java performance tuning
Jerry Kurian
 
DIY Java Profiling
Roman Elizarov
 
ContextualContinuous Profilng
Jaroslav Bachorik
 
Java Profiling Future
Jaroslav Bachorik
 
JavaOne 2015 Java Mixed-Mode Flame Graphs
Brendan Gregg
 
Java black box profiling JUG.EKB 2016
aragozin
 
Introduction to Java Profiling
Jerry Yoakum
 
Using Flame Graphs
Isuru Perera
 
Tuning Java Servers
Srinath Perera
 
Software Profiling: Understanding Java Performance and how to profile in Java
Isuru Perera
 
Impact2014: Introduction to the IBM Java Tools
Chris Bailey
 
Ad

More from LogeekNightUkraine (20)

PPTX
Face recognition with c++
LogeekNightUkraine
 
PPTX
C++20 features
LogeekNightUkraine
 
PPTX
Autonomous driving on your developer pc. technologies, approaches, future
LogeekNightUkraine
 
PDF
Orkhan Gasimov "High Performance System Design"
LogeekNightUkraine
 
PPTX
Vitalii Korzh "Managed Workflows or How to Master Data"
LogeekNightUkraine
 
PDF
Yevhen Tatarynov "From POC to High-Performance .NET applications"
LogeekNightUkraine
 
PDF
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
LogeekNightUkraine
 
PDF
Oleksandr Kutsan "Using katai struct to describe the process of working with ...
LogeekNightUkraine
 
PDF
Pavlo Zhdanov "Mastering solid and base principles for software design"
LogeekNightUkraine
 
PDF
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
LogeekNightUkraine
 
PPTX
Aleksandr Kutsan "Managing Dependencies in C++"
LogeekNightUkraine
 
PDF
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
LogeekNightUkraine
 
PDF
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"
LogeekNightUkraine
 
PPTX
Michal Kordas "Docker: Good, Bad or Both"
LogeekNightUkraine
 
PPTX
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
LogeekNightUkraine
 
PPTX
Shestakov Illia "The Sandbox Theory"
LogeekNightUkraine
 
PPTX
Dmytro Kochergin “Autotest with CYPRESS”
LogeekNightUkraine
 
PPTX
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
LogeekNightUkraine
 
PDF
Nhu Viet Nguyen "Why C++ is Becoming a Necessity for QA Automation"
LogeekNightUkraine
 
PDF
Dmytro Safonov "Open-Source Map Viewers"
LogeekNightUkraine
 
Face recognition with c++
LogeekNightUkraine
 
C++20 features
LogeekNightUkraine
 
Autonomous driving on your developer pc. technologies, approaches, future
LogeekNightUkraine
 
Orkhan Gasimov "High Performance System Design"
LogeekNightUkraine
 
Vitalii Korzh "Managed Workflows or How to Master Data"
LogeekNightUkraine
 
Yevhen Tatarynov "From POC to High-Performance .NET applications"
LogeekNightUkraine
 
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
LogeekNightUkraine
 
Oleksandr Kutsan "Using katai struct to describe the process of working with ...
LogeekNightUkraine
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
LogeekNightUkraine
 
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
LogeekNightUkraine
 
Aleksandr Kutsan "Managing Dependencies in C++"
LogeekNightUkraine
 
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
LogeekNightUkraine
 
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"
LogeekNightUkraine
 
Michal Kordas "Docker: Good, Bad or Both"
LogeekNightUkraine
 
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
LogeekNightUkraine
 
Shestakov Illia "The Sandbox Theory"
LogeekNightUkraine
 
Dmytro Kochergin “Autotest with CYPRESS”
LogeekNightUkraine
 
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
LogeekNightUkraine
 
Nhu Viet Nguyen "Why C++ is Becoming a Necessity for QA Automation"
LogeekNightUkraine
 
Dmytro Safonov "Open-Source Map Viewers"
LogeekNightUkraine
 
Ad

Recently uploaded (20)

PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PDF
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
 
PDF
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
Machine Learning Benefits Across Industries
SynapseIndia
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Integrating IIoT with SCADA in Oil & Gas A Technical Perspective.pdf
Rejig Digital
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
 
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
The Future of Artificial Intelligence (AI)
Mukul
 
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Machine Learning Benefits Across Industries
SynapseIndia
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Integrating IIoT with SCADA in Oil & Gas A Technical Perspective.pdf
Rejig Digital
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 

Iurii Antykhovych "Java and performance tools and toys"

  • 1. Java and Performance
 Tools and Toys 2021-02-25
  • 2. Agend a • Methodolog y • Metric s • Profiling, Profiler s • Use Case s • Profile Viewer s • Profiling target s • Distributed profilin g • Other tool s
  • 3. www.luxoft.com Starting Poin t 
 “Use The Right Tool at the Right Place” Anonymous plumber
 
 
 
 
 
 
 Great Learning course at Lux Learning : В. Сонькин, Java Advanced II: Performance Photo b y Simon Migaj @ unsplash.com
  • 4. www.luxoft.com Use the USE method : Resource List : ๏ CPUs: sockets, cores, hardware threads (virtual CPUs ) ๏ Memory: capacit y ๏ Network interface s ๏ Storage devices: I/O, capacit y ๏ Controllers: storage, network card s ๏ Interconnects: CPUs, memory, I/O http://www.brendangregg.com/usemethod.html
  • 5. www.luxoft.com Retrieving metrics : 
 Ad-hoc, manual : ๏ CPU: uptime, pidstat, top, vmstat, mpstat, etc . ๏ IO: sar, iostat, iotop, etc . ๏ Memory: free, top, et c ๏ Errors: dmes g ๏ …
 ๏ Swiss knife: dstat http://www.brendangregg.com/Articles/Netflix_Linux_Perf_Analysis_60s.pdf
  • 6. www.luxoft.com Monitoring both
 App and USE metrics:
 Metrics reporting : ๏ System: collectd, telegraf, etc . ๏ Java: Micromete r Metrics aggregation : ๏ Free: Prometheus/Grafana, etc . ๏ Commercial: NewRelic, DataDog, CloudWatch, etc . NewRelic metrics Dashboard https://micrometer.io
  • 7. www.luxoft.com Metrics: Use Cas e Alerts : ๏ High system/irq/steal/… time ๏ High iowait time ๏ Low utilization high saturatio n ๏ Spikes of any activit y ๏ Error spike s ๏ … Metrics collected by Ganglia ???
  • 8. www.luxoft.com Flamegraph s 
 
 Types : ๏ CP U ๏ Off-CP U ๏ Memory, Allocatio n ๏ Software/Hardware event s ๏ Composite (Hot/Cold), Differential http://www.brendangregg.com/flamegraphs.html
  • 9. www.luxoft.com Profiling and Profilers : 
 
 Profiler types : ๏ Instrumenting automate d ๏ Instrumenting manua l ๏ Samplin g ๏ … Survey by RebelLabs, RedHat Summit 2015, Lessons learned from the JBoss performance team JavaDay UA 2017: Nitsan Wakart. Profilers Are Lying Hobbitses 
 Better Profiler types : ๏ goo d ๏ bad
  • 10. www.luxoft.com Async Profiler : 
 
 Features : ๏ No use of JVMTI GetAllStackTraces(), Safepoint Bias-fre e ๏ Combines both worlds:
 Java frames - AsynGetCallTrace(), internal HotSpot API
 Native frames (user + kernel)- perf_event_open syscal l ๏ Flexible events: CPU cycles, tracepoints, native/Java methods, 
 PMU counter s ๏ Flexible modes: CPU profiling, Off-CPU profiling, Allocation profilin g ๏ Flexible output: bomb dump, “collapsed” (perf compatible), 
 JFR, flamegraphs, call trees, conversion scripts AP with Andrey Pangin: 4h-long (!!!) webinar: https://youtube.com/playlist?list=PLNCLTEx3B8h4Yo_WvKWdLvI9mj1XpTKBr https://www.vecteezy.com/free-vector/the-end
  • 11. www.luxoft.com Async Profiler : 
 
 
 Drawbacks : ๏ No Windows suppor t ๏ Allocation: same as JFR, slow path-only, 
 TLAB bias, no JEP-331 support
 Resolved in jvmti-tools/heapsampler project, YourKi t ๏ No system-wide profilin g ๏ No distributed profilin g ๏ Tricky cases: e.g. cpu time/cycles vs physical time https://github.com/apangin/codeone2019-java-profilin g Photo by Emiliano Vittoriosi @ unsplash.com
  • 12. www.luxoft.com Async Profiler : 
 Configuration : ๏ Allow collecting kernel frames:
 $ sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'
 $ sudo sh -c 'echo 0 >/proc/sys/kernel/kptr_restrict’
 Running : ๏ As JVM agent
 -XX:+DebugNonSafepoint s ๏ Attach to process
 -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoint s ๏ From Java application code
 
 https://www.baeldung.com/java-async-profiler Async Profiler help output
  • 13. www.luxoft.com Viewing Profiles : 
 Profile Formats : ๏ Summary (text ) ๏ Call Tre e ๏ HTML Flamegrap h ๏ SVG Flamegraph (v1.X, or requires flamegraph.pl script ) ๏ nflx (flamescope) 
 java -cp build/converter.jar jfr2nflx myprofile.jfr out.nfl x Third-party Viewers : ๏ IntelliJ IDEA Ultimate Editio n ๏ SpeedScope (https://www.speedscope.app ) ๏ FlameScope (https://github.com/Netflix/flamescope) SpeedScope FlameScope
  • 14. www.luxoft.com Showtime: Example 1 
 
 CPU, Wall-clock:
 Application structure revealed,
 
 Hot paths of execution highlighted
 in a very-very complex codebase. Module A Module B Module C
  • 15. www.luxoft.com Example 2 
 
 CPU - Native frames Business logic
 Only this part is visible in VisualVM / JMC (!!!) JVM went crazy with 600 threads
  • 16. www.luxoft.com Example 3 
 
 CPU, by Threads:
 GC at work Caption Business logic GC at work
  • 19. www.luxoft.com What to profile : 
 
 Production : ๏ Enable on all or part of the nodes in pro d Loadtests : ๏ Run nightly loadtests with profiling enable d ๏ Correlate the loadtest results with metrics and perf. profiles Benchmarks : ๏ JMH integration in sbt-jmh by Konrad Malawski
 https://github.com/ktoso/sbt-jmh
 As simple as: -prof jfr / -prof async Gatling Loadtest NewRelic Dashboard Performance Profile: JFR Flamegraphs
  • 20. www.luxoft.com Distributed profilin g 
 
 Collapsed flow : ๏ Collect collapsed or JFR file s ๏ Concatenate collected file s ๏ Convert to desired format: svg, html, nflx (flamescope) 
 Examples:
 ./flamegraph.pl --color java input.collapsed > out.svg
 java -cp build/converter.jar jfr2nflx myprofile.jfr out.nfl x ๏ Voila! View in favorite viewer JMC 8.0
  • 21. www.luxoft.com Profiling: Other options
 
 
 Commercial JVM profilers : ๏ Amazon CodeGur u ๏ Google Cloud Profile r ๏ Opsian (by creator of honest-profiler ) ๏ DataDog continuous profile r ๏ … Photo by Fabian Blank @ unsplash.com
  • 22. www.luxoft.com Where to go next ? 
 
 Things you might want to look at : ๏ PMU counters in Java
 S. Kuksenko: Speed up you Java App with Hardware Counters ๏ TMAM Method: Top-down Micro-architecture Analysi s ๏ Intel vTune Profile r ๏ AMD µPro f ๏ https://github.com/andikleen/pmu-tools, TopLe v ๏ eBP F ๏ …