SlideShare a Scribd company logo
1 of 33
Globalcode – Open4education
Inside the JVM - Performance &
Garbage Collector Tuning in JAVA
Rafael Monteiro e Pereira
Data Scientist – DataLabs Serasa Experian
Globalcode – Open4education
Agenda
Como a JVM funciona ?
Tools for performance analysis
GC analysis
Globalcode – Open4education
The JVM
Fonte: http://www.mauda.com.br/?p=872
Globalcode – Open4education
Java Mission Control
Available in JDK since Java 7 update 40
Two main tools: JMX Console & JFR
Globalcode – Open4education
Java Mission Control
The server VM needs to be started with following
options
-XX:+UnlockCommercialFeatures -XX:+FlightRecorder
Globalcode – Open4education
JMC->JMX Console
Captures and presents live data about:
Garbage Collection (GC) Pauses
Memory (Heap Usage)
CPU Usage
Other attributes exposes via Mbeans
Globalcode – Open4education
JMC->Flight Recorder
A profiling and event collection framework built into
the Oracle JDK
Gather low level information about the JVM and
application are behaving without performance
impact (less than 2%)
Globalcode – Open4education
JMC-> Demo
HotMethods
Latency
Memory Leak
Samples by Marcus Hint
http://hirt.se/blog/?p=611
Globalcode – Open4education
Thread Communication
Just Create a Queue
right ?
You are sure that you
wanna block ?
https://github.com/real-
logic/benchmarks
LinkedBlockingQueue 154
μs
ArrayBlockingQueue 56 μs
ConcurrentLinkedQueue 44 μs
Disruptor 3.0 20 μs
Globalcode – Open4education
Thread Communication
Disruptor (
https://github.com/LMAX-Exchange/disruptor
)
Very fast Inter-Thread
Message Library
Source: https://martinfowler.com/articles/images/lmax/arch-full.png
Globalcode – Open4education
Performance Test
Gattling.io
Globalcode – Open4education
Performance Test
val scn = {
scenario("resource test: host=" + hostUrl + ", users_count=" + usersCount)
.feed(usersDataSource)
.exec(http("getUserId")
.get("/gdc/app/account/bootstrap")
.basicAuth("${username}", "${password}")
.check(jsonPath("$.bootstrapResource.current.loginMD5")
.find.saveAs("userId")))
.repeat(requestsNumber) {
exec(http("processesView GET")
.get("/gdc/app/account/profile/${userId}/dataload/processesView")
.basicAuth("${username}", "${password}"))
.pause(requestPauseSeconds)
}}
Globalcode – Open4education
Performance Test
JMH
Building, running, and analysing
nano/micro/milli/macro benchmarks written in Java
and other languages targetting the JVM.
Globalcode – Open4education
Performance Test
JMH
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(1)
public AddressBookProtos.Person GPBDeserialization() {
try {
return AddressBookProtos.Person.parseFrom(msgGPB);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
return null;
}
Globalcode – Open4education
GC
Avoid “Stop the world” events
Usually a big problem if latency is a requirement.
G1
CMS
Shenandoah
Globalcode – Open4education
GC-> CMS
Globalcode – Open4education
GC - Tips
Paramters for CMS
-server
-Xms4048m e -Xmx4048m
-XX:+UseParallelGC
-XX:+ParallelOldGC
-XX:+UseConcMarkSweepGC
Globalcode – Open4education
GC->G1
Globalcode – Open4education
GC->G1
Fonte: http://presentations2015.s3.amazonaws.com/40_presentation.pdf
Globalcode – Open4education
GC->G1
Fonte: http://presentations2015.s3.amazonaws.com/40_presentation.pdf
Globalcode – Open4education
GC- TIPS
Parameters G1
-XX:+UseG1GC
-server
-Xms8g –Xmx8g
-XX:MaxGCPauseMillis=200
-XX:ParallelGCThreads=n
-XX:+ParallelRefProcEnabled
Globalcode – Open4education
GC-> Shenandoah
Ultra low latency GC
Fonte: https://wiki.openjdk.java.net/display/shenandoah/Main
Globalcode – Open4education
GC-> Shenandoah
Ultra low latency GC
-XX:+UseShenandoahGC
-XX:+UnlockExperimentalVMOptions
-XX:ShenandoahUncommitDelay=1000
-XX:ShenandoahGuaranteedGCInterval=10000
Fonte: https://wiki.openjdk.java.net/display/shenandoah/Main
Globalcode – Open4education
GC-> Shenandoah
Ultra low latency GC
Fonte: https://dzone.com/articles/choosing-the-right-gc
Globalcode – Open4education
GC-> Shenandoah
Ultra low latency GC->G1
Fonte: https://dzone.com/articles/choosing-the-right-gc
Globalcode – Open4education
GC - Tips
GC Logs
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
Xloggc:gc.log"
Globalcode – Open4education
GC - Log
GC G1
[GC pause (young) (to-space exhausted), 0.0406140
secs] 6229.691:
[Full GC 10G->5813M(12G), 15.7221680 secs]
Globalcode – Open4education
Off-Heap Allocation
Allocates memory outside the Heap
HARD ! Really !
Globalcode – Open4education
Off-Heap Allocation
Copy Object outside the Heap
Globalcode – Open4education
GC - Tips
Use a LIB !
Open HFT -> https://github.com/OpenHFT
https://github.com/OpenHFT/Java-Thread-Affinity
https://github.com/OpenHFT/Chronicle-Queue
https://github.com/OpenHFT/Chronicle-Logger
Some Tips
Be careful with big Heap sizes. Usually is not a good idea to go beyond 8
GB on Hotspot.
Big Heap == Slow GC !!! Consider using off-heap allocation if a lot of
information must be maintained in memory.
Globalcode – Open4education
Referencias
Oracle
Marcus Hirt blog
JMH
OpenJDK->JMH
Globalcode – Open4education
OBRIGADO !
E-mail: rafael@monteiro.io
Twitter: @monteiro_io
Github: github.com/rafamonteiro
LinkedIn: https://bit.ly/2jQQIXj
Slides -> https://bit.ly/2LaFMEd
Inside the JVM - Performance & Garbage Collector Tuning in JAVA

More Related Content

What's hot

Crossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic LanguagesCrossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic Languages
Bastian Kruck
 
Java in flames
Java in flamesJava in flames
Java in flames
Isuru Perera
 

What's hot (19)

Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
 
7 jvm-arguments-v1
7 jvm-arguments-v17 jvm-arguments-v1
7 jvm-arguments-v1
 
7 jvm-arguments-Confoo
7 jvm-arguments-Confoo7 jvm-arguments-Confoo
7 jvm-arguments-Confoo
 
16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
Ctf cli
Ctf cliCtf cli
Ctf cli
 
Troubleshooting performanceavailabilityproblems (1)
Troubleshooting performanceavailabilityproblems (1)Troubleshooting performanceavailabilityproblems (1)
Troubleshooting performanceavailabilityproblems (1)
 
Using Flame Graphs
Using Flame GraphsUsing Flame Graphs
Using Flame Graphs
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problems
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 
Major outagesmajorenteprises 2021
Major outagesmajorenteprises 2021Major outagesmajorenteprises 2021
Major outagesmajorenteprises 2021
 
Crossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic LanguagesCrossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic Languages
 
3DD 1e Linux
3DD 1e Linux3DD 1e Linux
3DD 1e Linux
 
Micro-metrics to forecast performance tsunamis
Micro-metrics to forecast performance tsunamisMicro-metrics to forecast performance tsunamis
Micro-metrics to forecast performance tsunamis
 
Usage of GDB
Usage of GDBUsage of GDB
Usage of GDB
 
Introduction to segmentation fault handling
Introduction to segmentation fault handling Introduction to segmentation fault handling
Introduction to segmentation fault handling
 
Cloud TiDB deep dive
Cloud TiDB deep diveCloud TiDB deep dive
Cloud TiDB deep dive
 
Java in flames
Java in flamesJava in flames
Java in flames
 

Similar to Inside the JVM - Performance & Garbage Collector Tuning in JAVA

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
tcloudcomputing-tw
 

Similar to Inside the JVM - Performance & Garbage Collector Tuning in JAVA (20)

Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019
 
Python + GDB = Javaデバッガ
Python + GDB = JavaデバッガPython + GDB = Javaデバッガ
Python + GDB = Javaデバッガ
 
jcmd #javacasual
jcmd #javacasualjcmd #javacasual
jcmd #javacasual
 
Adopting GraalVM - Scala eXchange London 2018
Adopting GraalVM - Scala eXchange London 2018Adopting GraalVM - Scala eXchange London 2018
Adopting GraalVM - Scala eXchange London 2018
 
this-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptxthis-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptx
 
Production Time Profiling Out of the Box
Production Time Profiling Out of the BoxProduction Time Profiling Out of the Box
Production Time Profiling Out of the Box
 
手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018
 
Apache httpd reverse proxy and Tomcat
Apache httpd reverse proxy and TomcatApache httpd reverse proxy and Tomcat
Apache httpd reverse proxy and Tomcat
 
Production Time Profiling and Diagnostics on the JVM
Production Time Profiling and Diagnostics on the JVMProduction Time Profiling and Diagnostics on the JVM
Production Time Profiling and Diagnostics on the JVM
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
Ob1k presentation at Java.IL
Ob1k presentation at Java.ILOb1k presentation at Java.IL
Ob1k presentation at Java.IL
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on Kubernetes
 
JVM and OS Tuning for accelerating Spark application
JVM and OS Tuning for accelerating Spark applicationJVM and OS Tuning for accelerating Spark application
JVM and OS Tuning for accelerating Spark application
 
How's relevant JMeter to me - DevConf (Letterkenny)
How's relevant JMeter to me - DevConf (Letterkenny)How's relevant JMeter to me - DevConf (Letterkenny)
How's relevant JMeter to me - DevConf (Letterkenny)
 
How to use TAU for Performance Analysis on Summit Supercomputer
How to use TAU for Performance Analysis on Summit SupercomputerHow to use TAU for Performance Analysis on Summit Supercomputer
How to use TAU for Performance Analysis on Summit Supercomputer
 
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
 

More from Rafael Monteiro e Pereira

More from Rafael Monteiro e Pereira (6)

Kubeflow - a caixa de ferramentas para tirar seus modelos do notebook e coloc...
Kubeflow - a caixa de ferramentas para tirar seus modelos do notebook e coloc...Kubeflow - a caixa de ferramentas para tirar seus modelos do notebook e coloc...
Kubeflow - a caixa de ferramentas para tirar seus modelos do notebook e coloc...
 
Microservices: Patterns & Practices
Microservices: Patterns & PracticesMicroservices: Patterns & Practices
Microservices: Patterns & Practices
 
Do mainframe para java, microservices e big data
Do mainframe para java, microservices e big dataDo mainframe para java, microservices e big data
Do mainframe para java, microservices e big data
 
Cassandra o que nao te contaram
Cassandra   o que nao te contaramCassandra   o que nao te contaram
Cassandra o que nao te contaram
 
Java for ultra low latency applications
Java for ultra low latency applicationsJava for ultra low latency applications
Java for ultra low latency applications
 
Explorando protocolos de serialização de alto desempenho
Explorando protocolos de serialização de alto desempenhoExplorando protocolos de serialização de alto desempenho
Explorando protocolos de serialização de alto desempenho
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 

Recently uploaded (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 

Inside the JVM - Performance & Garbage Collector Tuning in JAVA