SlideShare a Scribd company logo
1 of 55
Java Performance
Chapter 4
Saurav Basu
6/3/2020
1
Organization
1. Strategies, Approaches, and Methodologies
2. Operating System Performance Monitoring
3. JVM Overview
4. JVM Performance Monitoring
5. Java Application Profiling
6. Java Application Profiling - Tips & Tricks
7. Tuning the JVM - Step by Step
8. Benchmarking Java Applications
9. Benchmarking Multitiered Applications
10. Web Application Performance
11. Web Services Performance
12. Java Persistence & Enterprise Java Beans Performance
2
JVM Performance Monitoring
3
● Non Intrusive collection of performance data
● Proactive or Reactive
JVM Performance Monitoring
1. Garbage Collection
2. JIT Compiler
3. Class Loading
4. Java Application Monitoring
4
Metrics
JVM Performance Monitoring
1. Garbage Collection
2. JIT Compiler
3. Class Loading
4. Java Application Monitoring
5
JVM Performance Monitoring
6
SNo Description Metric Type
1 Garbage Collector Type
2 Java Heap Size
3 Young Generation & Old Generation Space Size
4 Permanent Generation Space Size
5 Minor Garbage Collection Duration
6 Minor Garbage Collection Frequency
7 Minor Garbage Collection Reclaimed Space
8 Full Garbage Collection Duration
9 Full Garbage Collection Frequency
10 Concurrent Garbage Collection Space Reclaimed
11 Java Heap before & after Garbage Collection Occupancy
12 Young & Old Gen before & after Garbage Collection Occupancy
13 Perm Gen space before & after Garbage Collection Occupancy
14 Old or Perm Gen trigger Full Garbage Collection Boolean
15 Explicit GC Calls Boolean
Garbage Collection
JVM Performance Monitoring
7
Garbage Collection
-XX+PrintGCDetails
Minor GC
Young Generation Occupancy (before & after) Young Generation Size
Total Occupancy (Before & After)
Total Heap Size
Old Gen Size = Total Heap Size - Young Gen Size (764672-109312)=655360K
JVM Performance Monitoring
8
Garbage Collection
-XX+PrintGCDetails
Total Live Data
Occupancy ~ Total Old Gen Size
Total Time
JVM Performance Monitoring
9
Garbage Collection
-XX+PrintGCDetails
(CMS) Multi threaded GC
Elapsed Time (GC)
JVM Performance Monitoring
10
Garbage Collection Mark
Sweep
JVM Performance Monitoring
11
Garbage Collection
Note Occupancy Change
JVM Performance Monitoring
12
Garbage Collection
-XX+TenuringDistribution
Target Utilization
Max #GC cycles before promotion
JVM Performance Monitoring
13
Garbage Collection
-XX+TenuringDistribution
Utilization > Target
Max #GC cycles before promotion
New Tenuring
Threshold
JVM Performance Monitoring
14
Garbage Collection
-XX+PrintGCTimeStamps
With the inclusion of date and/or time stamps, calculate an expected frequency that minor
and full garbage collections occur
JVM Performance Monitoring
15
Garbage Collection
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
JVM Performance Monitoring
16
Garbage Collection Time b/w safe points
GC Time
JVM Performance Monitoring
17
Garbage Collection
Explicit System.gc()
JVM Performance Monitoring
18
Garbage Collection
Offline Analysis (GCHisto)
Guideline <10%
<SLA
JVM Performance Monitoring
19
Garbage Collection
GC Pause Distribution
JVM Performance Monitoring
20
Garbage Collection
GC Timeline
JVM Performance Monitoring
21
Garbage Collection
GC Timeline (Zoom)
JVM Performance Monitoring
22
Garbage Collection
Graphical Tools (JConsole)
JVM Performance Monitoring
23
Garbage Collection
Graphical Tools (JConsole)
JVM Performance Monitoring
24
Garbage Collection
Graphical Tools (JConsole)
JVM Performance Monitoring
25
Garbage Collection
Graphical Tools (JConsole)
(Eden + Survivor + Tenured)
Summary stats
JVM Performance Monitoring
26
Garbage Collection
Graphical Tools (JConsole)
1 Used
The amount of memory currently used, including the memory
occupied by all Java objects, both reachable and unreachable
2 Committed
The amount of memory guaranteed to be available for use by
the JVM
3 Max
The maximum amount of memory that can be used for memory
management
4 GC Time
The cumulative time spent in stop-the-world garbage collections
and the total number of garbage collection invocations including
concurrent garbage collection cycles
JVM Performance Monitoring
27
Garbage Collection
Graphical Tools (VisualVM)
JVM Performance Monitoring
28
Garbage Collection
Graphical Tools (VisualVM)
Launch
JVM Performance Monitoring
29
Garbage Collection
Graphical Tools (VisualVM)
JVM Performance Monitoring
30
Garbage Collection
Graphical Tools (VisualVM)
Remote Monitoring (Jstatd)
JVM
Jstatd RMI
Server
JPS
VisualVM
Policy File
Remote m/c
Local m/c
JVM Performance Monitoring
31
Garbage Collection
Graphical Tools (VisualVM)
Remote Monitoring (Jstatd)
Verify connection
Policy File
Start Daemon
JVM Performance Monitoring
32
Garbage Collection
Graphical Tools (VisualVM)
JVM Performance Monitoring
33
Garbage Collection
Graphical Tools (VisualVM)
JVM Performance Monitoring
34
Garbage Collection
Monitor subtab (VisualVM)
JVM Performance Monitoring
35
Garbage Collection
Remote Monitoring via JMX
JMX Setup Tutorial
JVM Performance Monitoring
36
Garbage Collection
Remote Monitoring via JMX (VisualVM)
Increased Monitoring
Capability!!JMX Icon
Threads Tab
JVM Performance Monitoring
37
Garbage Collection
Remote Monitoring via JMX (VisualVM)
JVM Performance Monitoring
38
Garbage Collection
Remote CPU Profiling (VisualVM) Profile Start/Stop
Relative Time
Wall Clock Time
JVM Performance Monitoring
39
Garbage Collection
Saving a snapshot (VisualVM)
View Hotspot
Method consuming
most selfTime
Thread Call stack
Save/Export
Snapshot
JVM Performance Monitoring
40
Garbage Collection
Dump File
JAVA 5 jmap -dump:format=b, file=<filename> <jvm pid>
JAVA 6 jmap -heap:format=b, file=<filename> <jvm pid>
A binary heap dump is a snapshot of all the objects in the JVM heap at the time
when the heap dump is taken
JVM Performance Monitoring
41
Garbage Collection
Visual GC
Plug-In
JVM Performance Monitoring
42
Garbage Collection
Visual GC
Height ⍺ Allocation
Bucket View
Heap Utilization Moving Window View
1. Compilation
2. GC Stat
Histogram View
Object Age
JVM Performance Monitoring
43
Garbage Collection
Visual GC
Commited
Memory
(dark grey)
Reserved memory
(light grey)
Minor GC
JVM Performance Monitoring
1. Garbage Collection
2. JIT Compiler
3. Class Loading
4. Java Application Monitoring
44
JVM Performance Monitoring
45
JIT Compiler
-XX:+PrintCompilation
Timestamp
(since VM start)
On Stack Replacement
Exception handler
synchronized
native
Blocking compiler
Invalid Code
JVM Performance Monitoring
46
JIT Compiler
Visual GC (Compile Time Panel)
Compile Task Execution Count
Aggregated Duration
JVM Performance Monitoring
1. Garbage Collection
2. JIT Compiler
3. Class Loading
4. Java Application Monitoring
47
JVM Performance Monitoring
48
Class Loading
JVM Performance Monitoring
49
Class Loading (JConsole)
Time Window
Class Load Count
JVM Performance Monitoring
50
Class Loading (VisualVM)
Shared Memory
JVM Performance Monitoring
51
Class Loading
Accumulated Class Load Time
Visual GC (Class Loader Panel)
Load & Unload Count
JVM Performance Monitoring
52
Java Application Monitoring
LockId Contention
JVM Performance Monitoring
1. Garbage Collection
2. JIT Compiler
3. Class Loading
4. Java Application Monitoring
53
JVM Performance Monitoring
54
Java Application Monitoring (Tomcat)
Application Name
Active
Session
Count
JVM Performance Monitoring
55
Java Application Monitoring (Tomcat)
Lock Contention
jps -v
jstack <pid>

More Related Content

What's hot

Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVMSimon Ritter
 
Use open stack to run java programs inside a Docker container
Use open stack to run java programs inside a Docker containerUse open stack to run java programs inside a Docker container
Use open stack to run java programs inside a Docker containerMiano Sebastiano
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friendKai Koenig
 
JVM memory management & Diagnostics
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & DiagnosticsDhaval Shah
 
Discuss about java 9 with latest features
Discuss about java 9 with latest featuresDiscuss about java 9 with latest features
Discuss about java 9 with latest featuresNexSoftsys
 
kubeadmのしくみ
kubeadmのしくみkubeadmのしくみ
kubeadmのしくみheriet
 

What's hot (10)

Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVM
 
Java GC, Off-heap workshop
Java GC, Off-heap workshopJava GC, Off-heap workshop
Java GC, Off-heap workshop
 
Use open stack to run java programs inside a Docker container
Use open stack to run java programs inside a Docker containerUse open stack to run java programs inside a Docker container
Use open stack to run java programs inside a Docker container
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
JVM memory management & Diagnostics
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & Diagnostics
 
Discuss about java 9 with latest features
Discuss about java 9 with latest featuresDiscuss about java 9 with latest features
Discuss about java 9 with latest features
 
Java On Speed
Java On SpeedJava On Speed
Java On Speed
 
kubeadmのしくみ
kubeadmのしくみkubeadmのしくみ
kubeadmのしくみ
 
GlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium ParisGlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium Paris
 

Similar to JavaPerformanceChapter_4

JavaPerformanceChapter_5
JavaPerformanceChapter_5JavaPerformanceChapter_5
JavaPerformanceChapter_5Saurav Basu
 
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA Rafael Monteiro e Pereira
 
Taming Java Garbage Collector
Taming Java Garbage CollectorTaming Java Garbage Collector
Taming Java Garbage CollectorDaya Atapattu
 
Java PerformanceChapter_7
Java PerformanceChapter_7Java PerformanceChapter_7
Java PerformanceChapter_7Saurav Basu
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020Jelastic Multi-Cloud PaaS
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderIsuru Perera
 
JavaPerformanceChapter_3
JavaPerformanceChapter_3JavaPerformanceChapter_3
JavaPerformanceChapter_3Saurav Basu
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaIsuru Perera
 
JavaPerformanceChapter_8
JavaPerformanceChapter_8JavaPerformanceChapter_8
JavaPerformanceChapter_8Saurav Basu
 
Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019Petr Zapletal
 
millions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxmillions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxTier1 app
 
IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8Chris Bailey
 
Web Sphere Problem Determination Ext
Web Sphere Problem Determination ExtWeb Sphere Problem Determination Ext
Web Sphere Problem Determination ExtRohit Kelapure
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Dinakar Guniguntala
 
JRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell YouJRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell Youelliando dias
 
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...Jelastic Multi-Cloud PaaS
 
Session 3 - CloudStack Test Automation and CI
Session 3 - CloudStack Test Automation and CISession 3 - CloudStack Test Automation and CI
Session 3 - CloudStack Test Automation and CItcloudcomputing-tw
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunningguest1f2740
 

Similar to JavaPerformanceChapter_4 (20)

JavaPerformanceChapter_5
JavaPerformanceChapter_5JavaPerformanceChapter_5
JavaPerformanceChapter_5
 
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
 
Taming Java Garbage Collector
Taming Java Garbage CollectorTaming Java Garbage Collector
Taming Java Garbage Collector
 
Java PerformanceChapter_7
Java PerformanceChapter_7Java PerformanceChapter_7
Java PerformanceChapter_7
 
Temadag om-java-jamaica vm-2013-09
Temadag om-java-jamaica vm-2013-09Temadag om-java-jamaica vm-2013-09
Temadag om-java-jamaica vm-2013-09
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight Recorder
 
JavaPerformanceChapter_3
JavaPerformanceChapter_3JavaPerformanceChapter_3
JavaPerformanceChapter_3
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
JavaPerformanceChapter_8
JavaPerformanceChapter_8JavaPerformanceChapter_8
JavaPerformanceChapter_8
 
Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019
 
millions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxmillions-gc-jax-2022.pptx
millions-gc-jax-2022.pptx
 
NZS-4409 - Enterprise Java Monitoring on zOS Discover, Alert, Optimize
NZS-4409 - Enterprise Java Monitoring on zOS Discover, Alert, OptimizeNZS-4409 - Enterprise Java Monitoring on zOS Discover, Alert, Optimize
NZS-4409 - Enterprise Java Monitoring on zOS Discover, Alert, Optimize
 
IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8IBM Monitoring and Diagnostic Tools - GCMV 2.8
IBM Monitoring and Diagnostic Tools - GCMV 2.8
 
Web Sphere Problem Determination Ext
Web Sphere Problem Determination ExtWeb Sphere Problem Determination Ext
Web Sphere Problem Determination Ext
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !
 
JRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell YouJRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell You
 
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
 
Session 3 - CloudStack Test Automation and CI
Session 3 - CloudStack Test Automation and CISession 3 - CloudStack Test Automation and CI
Session 3 - CloudStack Test Automation and CI
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 

More from Saurav Basu

JavaPerformanceChapter_12
JavaPerformanceChapter_12JavaPerformanceChapter_12
JavaPerformanceChapter_12Saurav Basu
 
JavaPerformanceChapter_9
JavaPerformanceChapter_9JavaPerformanceChapter_9
JavaPerformanceChapter_9Saurav Basu
 
JavaPerformanceChapter_11
JavaPerformanceChapter_11JavaPerformanceChapter_11
JavaPerformanceChapter_11Saurav Basu
 
JavaPerformanceChapter_10
JavaPerformanceChapter_10JavaPerformanceChapter_10
JavaPerformanceChapter_10Saurav Basu
 
JavaPerformanceChapter_6
JavaPerformanceChapter_6JavaPerformanceChapter_6
JavaPerformanceChapter_6Saurav Basu
 
JavaPerformanceChapter_2
JavaPerformanceChapter_2JavaPerformanceChapter_2
JavaPerformanceChapter_2Saurav Basu
 
JavaPerformanceChapter_1
JavaPerformanceChapter_1JavaPerformanceChapter_1
JavaPerformanceChapter_1Saurav Basu
 
Application Deployment Architecture
Application Deployment ArchitectureApplication Deployment Architecture
Application Deployment ArchitectureSaurav Basu
 

More from Saurav Basu (8)

JavaPerformanceChapter_12
JavaPerformanceChapter_12JavaPerformanceChapter_12
JavaPerformanceChapter_12
 
JavaPerformanceChapter_9
JavaPerformanceChapter_9JavaPerformanceChapter_9
JavaPerformanceChapter_9
 
JavaPerformanceChapter_11
JavaPerformanceChapter_11JavaPerformanceChapter_11
JavaPerformanceChapter_11
 
JavaPerformanceChapter_10
JavaPerformanceChapter_10JavaPerformanceChapter_10
JavaPerformanceChapter_10
 
JavaPerformanceChapter_6
JavaPerformanceChapter_6JavaPerformanceChapter_6
JavaPerformanceChapter_6
 
JavaPerformanceChapter_2
JavaPerformanceChapter_2JavaPerformanceChapter_2
JavaPerformanceChapter_2
 
JavaPerformanceChapter_1
JavaPerformanceChapter_1JavaPerformanceChapter_1
JavaPerformanceChapter_1
 
Application Deployment Architecture
Application Deployment ArchitectureApplication Deployment Architecture
Application Deployment Architecture
 

Recently uploaded

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Recently uploaded (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

JavaPerformanceChapter_4

Editor's Notes

  1. Next we will discuss the topic of JVM Performance Monitoring
  2. what is performance monitoring?
  3. monitoring data is collected for the following areas garbage collection, jit compiler and class loading, we will also discuss application level monitoring.
  4. Lets first look at garbage collection monitoring
  5. List of metrics to monitor in the garbage collector
  6. This slide shows an entry in the gc log by enabling the printgcdetails flag. It shows the type of GC. the young gen occupancy Before and after gc and the total size of young gen, it also shows the total heap occupancy before and after gc and total heap size. 0.0631991 secs indicates the elapsed time for the garbage collection. [Times: user=0.83 sys=0.00, real=0.06 secs] provides CPU usage and elapsed time information. The value to the right of user is the CPU time used by the garbage collection executing instructions outside the operating system. In this example, the garbage collector used 0.06 seconds of user CPU time.The user time includes total user mode cpu time across all cpus and hence is higher than wall clock time
  7. This slide highlights another example of print gc details. In this example the gc is a full gc and the livedata size is the occupancy of old gen after full gc. Note That the occupancy of old gen is almost equal to the size of the old generation in this case. The log shows 1.117891 secs were spent on full gc The user mode sys and wall clock time for gc are shown below
  8. This is an example of young generation gc using the CMS garbage collector. In this example the minor gc took 0.083 sec Note that total user time is 0.02 secs includes time for all the threads on different cpu taken together 0.0838519 secs indicates the elapsed time for the minor garbage collection including the time it took to garbage collect the young generation space and promote any objects to old generation along with any remaining final cleanup work
  9. This slide shows another example of cms gc with the mark and sweep phases indicated on the slide
  10. In this slide note tha there is little change in occupancy of old gen space before and after gc. If there is little change in occupancy between the start and end of the CMS concurrent sweep phase, then either few objects are being garbage collected, meaning the CMS garbage collection cycles are finding few unreachable objects to garbage collect and as a result are wasting CPU, or objects are being promoted into the old generation space at a rate that is equal to or greater than the rate at which the CMS concurrent sweep phase is able to garbage collect them
  11. In this slide we look at the output of the JVM option Tenuring Distribution This will prints details of the heap space used by objects of different ages. The first line tells us that the target utilization of the “To” survivor space is about 75 MB. It also shows information about the “tenuring threshold”, which represents the number of GCs that an object may stay in the young generation before it is moved into the old generation (i.e., the maximum age of the object before it gets promoted). In this example, we see that the current tenuring threshold is 15 and that its maximum value is 15 as well.
  12. In this slide not that the total heap space utilization ~83MB is greater than target utilization of 75MB resulting in survivor space overflow.
  13. This slide shows an example of using the JVM option PrintGCTimeStamps The format of time printed is as described below: /* YYYY is the four-digit year. MM is the two-digit month; single-digit months are prefixed with 0. DD is the two-digit day of the month; single-digit days are prefixed with 0. T is a literal that denotes a date to the left of the literal and a time of day to the right. HH is the two-digit hour; single-digit hours are prefixed with 0. MM is the two-digit minute; single-digit minutes are prefixed with 0. SS is the two-digit second; single-digit seconds are prefixed with 0. mmm is the three-digit milliseconds; single- and two-digit milliseconds are pre- fixed with 00 and 0, respectively. TZ is the time zone offset from GMT */
  14. Let us now discuss 2 additional commandline options PrintGCApplicationStoppedTime shows how much time the application was stopped at safepoint PrintGCApplicationConcurrentTime is how much time the application worked without stopping, i.e. the time between two successive safepoints
  15. The output in this slide shows shows that the application ran for approximately .53 and .91 seconds with minor garbage collection pauses of approximately .046 seconds. That equates to about 5% to 8% overhead for minor garbage collections
  16. This slide show the System keyword is used to identify an explicit call for garbage collection
  17. This slide shows the usage of the offline gchisto tool to identify issues with the garbage collector. Take note of the overhead column and try to tune the gc to achieve < 10% overhead And max gc time less than sla. The garbage collection overhead (the Overhead % column) is an indicator of how well the garbage collector is tuned. As a general guideline, concurrent garbage collec- tion overhead should be less than 10%. It may be possible to achieve 1% to 3%. For the throughput garbage collector, garbage collection overhead near 1% is considered as having a well-tuned garbage collector. 3% or higher can be an indication that tun- ing the garbage collector may improve the application’s performance. It is important to understand there is a relationship between garbage collection overhead and the size of the Java heap
  18. This slide shows the histogram of pause times for the young generation where x-axis is the duration and y axis is the count. A wide distribution indicates swings in object allocation rates or promotion rates. In case wide swings are observed looking at the gc timeline tab can help identify peaks in gc activity
  19. This slide shows timeline view of the gc histo tool. The default view for the GC Timeline shows all garbage collection pauses through the entire time line. To see time stamps at the bottom of the graph (the x-axis), you must have garbage collection statistics that include either -XX:+PrintGCTimeStamps, -XX:+PrintGCDateStamps, A tick is put on the graph duration and time when gc pause occurred Selecting only full garbage collections as the pause type is useful for this analysis. With the timeline you can observe when the full garbage collections occur relative to the start of the JVM to get a sense of when they occurred Selecting only minor garbage collections as the pause type to show allows you to observe peaks, or possibly repeating peaks, in garbage collection duration over time. Any observed peaks or repeating patterns can be mapped back to application logs to get a sense of what is happening in the system at that time when the peaks occur. The use cases being executed at those time periods can be candidates to further explore for object allocation and object retention reduction opportunities. Reducing object allocation and object retention during these busiest garbage collection activity time periods reduces the frequency of minor garbage collections and potentially reduces the frequency of full garbage collections
  20. This slide shows the zoom feature of GC timeline tab Zooming in allows you to narrow the focus of the time line to a specific area to see each garbage collection pause. You can zoom back out by pressing the right mouse button anywhere in the graph and selecting Auto Range > Both Axes from the context sensitive menu GCHisto also provides the capability to load more than one garbage collection log at a time via the Trace Management tab When multiple garbage collection logs are loaded, there is a separate tab for each garbage collection log, which allows you to easily switch between logs. This can be useful when you want to compare garbage collection logs between different Java heap configurations or between different appli- cation loads
  21. This slide shows coomand to start the Demo application on Linux and Windows
  22. This slide shows the Jconsole tool startup screen. When JConsole is launched it automatically discovers and provides the oppor tunity to connect to Java applications running locally or remotely
  23. This slide shows the new connection dialog screen in jconsole. Select Name and PID of the application from the list and click the Connect button. To monitor an application on a remote system, the application to be monitored must be started with remote management enabled. Enabling remote management involves identifying a port number to communicate with the monitored application and establishing password authentication along with optionally using SSL for security.
  24. This slide shows graphical heap memory usage in jconsole Memory tab. Once a JConsole is connected to an application it will load six tabs. The default JConsole display between Java 5 and Java 6 differs. Java 6’s JConsole displays a graphical representation of heap memory, thread, classes, and CPU usage. In contrast, Java 5’s JConsole displays the same information but in a textual form. For the purposes of monitoring JVM garbage collection, the Memory tab is the most useful. The Memory tab in both Java 5 and Java 6 JConsole are the same. Figure shows the JConsole Memory tab A pattern to watch for is whether the survivor space remains full for an extended period of time. This is an indication that survivor spaces are overflowing and objects are getting promoted into the old generation space before they have an opportunity to age Tuning the young generation space can address survivor spaces overflowing
  25. This slide shows difference between used commited max and GCtime labels shown in jconsole memory tab
  26. In this slide we introduce visualvm tool This is a second generation of the JConsole tool and integrates with several existing JDK software tools and lightweight memory monitoring tools such as JConsole along with adding profiling capabilities found in the popular NetBeans Profiler. The tool utilizes the NetBeans plug-in architecture, which allows the ability to easily add components, add plug-ins, or extend VisualVM’s existing components or plug-ins to performance monitor or profile any application
  27. This slide shows the command to launch visualvm VisualVM can be launched from Windows, Linux, or Solaris using the following command line. (Note the command name is jvisualvm, not just visualvm)
  28. This slide shows the applications panel of VisualVM that has three major nodes in an expandable tree. The first major node, Local, contains a list of local Java applications VisualVM can monitor. The second node, Remote, contains a list of remote hosts and Java applications on each remote host VisualVM can monitor. The third node, Snapshots, contains a list of snapshot files. With VisualVM you can take a snapshot of a Java application’s state. When a snapshot is taken, the Java application’s state is saved to a file and listed under the Snapshots node. Snapshots can be useful to capture important state about the application or to compare it against a different snapshot
  29. This slide depicts the setup to configure visualvm for remote monitoring jvm The remote system must be configured to run the jstatd daemon The jstatd daemon launches a Java RMI server application that watches for the creation and termination of HotSpot VMs and provides an interface to allow remote monitoring tools such as VisualVM to attach and monitor Java applications remotely. The jstatd daemon must be run with the same user credentials as those of the Java applications to be monitored
  30. This slide shows a sample policy file for remote monitoring setup. Example policy file that can be used with jstatd This policy is less liberal than granting all permissions to all codebases but is more liberal than a policy that grants the minimal permissions to run the jstatd server Example of command to start the jstatd daemon jps is a command that lists the Java applications that can be monitored. When jps is supplied a hostname, it attempts to connect to the remote system’s jstatd daemon to discover which Java applications can be monitored remotely
  31. Figure shows VisualVM with a remote system configured and the Java applications it can monitor. To monitor an application double-click an application name or icon under the Local or Remote node or right-click on the application name or icon and select Open. Any of these actions opens a window tab in the right panel of VisualVM
  32. This slide shows the Overview window which provides a high level overview of the monitored application by showing the process id, host name where the application is running, main Java class name, any arguments passed to the application, the JVM name, the path to the JVM, any JVM flags used, whether heap dump on out of memory error is enabled or disabled, number of thread dumps or heap dumps have been taken, and, if available, the monitored application’s system properties
  33. This slide shows the monitor subtab of visualvm The Monitor window displays Heap usage, permanent generation space usage, classes loaded information, and number of threads. An example of the Monitor window monitoring an application running remotely under Java 6 is shown in Figure
  34. Link to documentation to configure VisualVM with JMX
  35. This slide depicts a remote connection in visualvm After a JMX connection is configured, an additional icon is displayed in VisualVM Application panel representing that a remote JMX connection has been configured to the remote application. Configuring a JMX connection for remote applications in VisualVM increases the monitoring capabilities. For example, the Monitor window also shows CPU usage by the application and the ability to induce a full garbage collection or heap dump, as shown in Figure In addition to more capabilities in the Monitor window, an additional Threads window is also available
  36. This slide describes the threads tab in visualvm. The Threads window offers insight into which threads are most active, those that are involved in acquiring and releasing locks The Threads window can be useful to observing specific thread behavior in an application, especially when operating system monitoring suggests the application may be experiencing lock contention An additional option available in the Threads window is the ability to create a thread dump by clicking the Thread Dump button. When a thread dump is requested, VisualVM adds a window tab displaying the thread dump and also appends a thread dump entry to the monitored application entry in the Application’s window below the application being monitored. It is important to note that thread dumps are not persisted or available once VisualVM has been closed unless they are saved. Thread dumps can be saved by right-clicking on the thread dump icon or label below the application listed in the Applications panel. Thread dumps can be reloaded in VisualVM at a later time by selecting the File > Load menu item and traversing to the directory where the thread dump was saved
  37. VisualVM also offers profiling capabilities to both local and remote applications. Local profiling capabilities include both CPU and memory profiling for Java 6 applications Being able to monitor CPU utilization while an application is running can provide information as to which methods are the busiest during times when specific events are occurring. For example, a GUI application may exhibit performance issues only in a specific view. Hence, being able to monitor the GUI application when it is in that view can be helpful in isolating the root cause Remote profiling requires a JMX connection to be configured and is limited to CPU profiling. It does not include memory profiling. But heap dumps can be generated from the Sampler window. They can also be generated from the Threads window. Heap dumps can be loaded into VisualVM to analyze memory usage Figure shows the Sampler window after clicking the CPU button. The view of CPU utilization is presented with the method name consuming the most time at the top. The second column, Self Time %, provides a histogram view of the method time spent per method relative to the time spent in other methods. The Self Time column represents the amount of wall clock time the method has consumed. The remaining column, Self Time (CPU), reports the amount of CPU time the method has consumed. Any of the columns can be sorted in ascending or descending order by clicking on the column name. A second click on a column causes the ordering to toggle back and forth between ascending or descending
  38. In the snapshot window, the call tree showing the call stacks for all threads in the captured snapshot are displayed. Each call tree can be expanded to observe the call stack and method consuming the most time and CPU. At the bottom of the snapshot window you can also view Hot Spots, which is a listing of methods with the method consuming the most Self Time at the top of the table. A combined view of the Call Tree and Hot Spots is also available. In the combined view, as you click on a call stack in the Call Tree, the table of Hot Spot methods is updated to show only the methods in the selected call stack
  39. VisualVM also has the capability to load binary heap dumps generated using jmap, JConsole, or upon reaching an OutOfMemoryError and using the -XX:+Heap DumpOnOutOfMemoryError HotSpot VM command line option
  40. VisualGC is a plug-in for VisualVM. VisualGC can monitor garbage collection, class loader, and JIT compilation activities. It was originally developed as a standalone GUI program. It can be used as both a standalone GUI or as a plug-in for VisualVM to monitor 1.4.2, Java 5, and Java 6 JVMs. When VisualGC was ported to a VisualVM plug-in some additional enhancements were made to make it easier to discover and connect to JVMs After the VisualGC plug-in has been added to VisualVM, when you monitor an application listed in the Applications panel, an additional window tab is displayed in the right panel labeled VisualGC
  41. VisualGC displays two or three panels depending on the garbage collector being used. When the throughput garbage collector is used, VisualGC shows two panels: the Spaces and Graphs panels. When the concurrent or serial garbage collector is used a third panel is shown below the Spaces and Graphs panels called Histogram. Figure shows VisualGC with all panel spaces The Spaces panel provides a graphical view of the garbage collection spaces and their space utilization. This panel is divided into three vertical sections, one for each of the garbage collection spaces: Perm (Permanent) space, Old (or Tenured) space, and the young generation space consisting of eden, and two survivor spaces, S0 and S1. The screen areas representing these garbage collection spaces are sized proportionately to the maximum capacities of the spaces as they are allocated by the JVM
  42. Uncommitted memory (virtual allocation) is represented by a light gray colored portion of the grid, whereas committed memory (physical ram) is represented by a darker gray colored portion The two survivor spaces are usually identical in size and its memory space fully committed. The eden space may be only partially committed, especially earlier in an application’s life cycle WatchFor :- survivor spaces overflowing. Survivor spaces overflowing can be identified by observing their occupancies at minor garbage collections Each rise and fall represents a minor gc
  43. Although the result of JIT compilation results in a faster running application, JIT compilation requires computing resources such as CPU cycles and memory to do its work Hence, it is useful to observe JIT compiler behavior
  44. The title bar of the display shows the total number of JIT compilation tasks and the accumulated amount of time spent performing compilation activity
  45. Next we will look at classloading
  46. The reporting of classes being unloaded during the full garbage collection provides evidence the permanent generation space may need to be sized larger, or its initial size may need to be larger Set the -XX:PermSize and -XX:MaxPermSize command line options
  47. Jconsole Classes Tab shows → Total loaded classes and current loaded classes
  48. VisualVM Monitor tab show classes loaded in shared memory over a time window information
  49. VisualGC ClassLoader Panel shows the number of classes loaded, the number of classes unloaded, and the accumulated class loading time since the start of the application
  50. Reader thread 33 acquired lock with hex address 0x22e88b10 Writer thread 29 is waiting to lock 0x22e88b10 Observation of multiple thread stack traces trying to lock the same lock address is an indication the application is experiencing lock contention It is important to note that the stack trace output of jmap provides the specific source code location of the contendedlock
  51. Next we will talk about java application monitoring
  52. Monitoring at the application level usually involves observing application logs that contain events of interest or instrumentation that provides some level of informa- tion about the application’s performance. Some applications also build-in monitoring and management capabilities using MBeans via Java SE’s monitoring and manage- ment APIs. These MBeans can be viewed and monitored using JMX compliant tools such as JConsole or using the VisualVM-MBeans plug-in within VisualVM Figure shows a portion of the many Tomcat MBeans in the MBeans window in VisualVM using the VisualVM-MBeans plug-in
  53. Example of jps & jstack command usage for lock detection