SlideShare une entreprise Scribd logo
1  sur  29
Java Garbage Collection: 
A Performance Impact 
Blynov Viacheslav 
Lead Software Developer 
24 November 2014 
www.luxoft.com
Introduction 
www.luxoft.com
Introduction 
Agenda 
 Garbage Collection Overview 
 Java GC Algorithms 
 Basic GC Tuning 
www.luxoft.com
www.luxoft.com
GC Purpose 
Objects that are referenced are said to be live 
Objects that are no longer referenced are considered dead and termed garbage 
Garbage collector is responsible for: 
 allocating memory 
 ensuring that any referenced objects remain in memory 
 recovering memory used by objects that are no longer reachable from references in 
executing code 
www.luxoft.com
www.luxoft.com
GC performance impact 
 Collector needs computational resources (CPU cycles) to perform garbage collection 
 As garbage collection involves moving objects in memory a collector must ensure that no 
thread is using these objects 
www.luxoft.com 
The pauses when all application threads are stopped are called 
stop-the-world pauses 
These pauses generally have the greatest impact on the performance of an application, and 
minimizing those pauses is the key consideration when tuning GC.
Generational model 
www.luxoft.com
Generational model 
www.luxoft.com
Generational model 
www.luxoft.com
Generational model 
www.luxoft.com
Generational model 
www.luxoft.com
Generational model 
www.luxoft.com
Summary 
 all GC algorithms divide the heap into old and young generation 
 all GC algorithm employ stop-the-world approach to clearing objects from 
young generation, which is usually a very quick operation 
www.luxoft.com
www.luxoft.com
“Client” and “Server” JVM types 
Depending on underlying hardware platform and version 
JVM can act as “client” of “server” VM. This affect the 
choice of JIT compiler and default GC algorithm. 
 “client” platform is usually 32-bit and has 1 CPU 
 “server” platform is usually 64-bit (but 32-bit is also 
possible) and has several CPUs 
www.luxoft.com
GC Algorithms 
 Serial garbage collector (-XX:+UseSerialGC) 
 Throughput collector (-XX:+UseParallelGC , -XX:+UseParallelOldGC) 
 CMS collector (-XX:+UseConcMarkSweepGC, -XX:+UseParNewGC) 
 G1 collector (-XX:+UseG1GC) 
www.luxoft.com
Serial garbage collector 
 default collector for client-class platforms (32-bit JVMs on Windows or single-processor 
www.luxoft.com 
machines) 
 uses single thread to process heap 
 stops all application threads for both minor and full GC 
Usage cases: 
 no low-pause requirements 
 “client-style” single-CPU environment 
 very small heap (few hundred MBs) 
 several JVMs running on single platform (number of JVM > number of 
available CPUs)
Throughput (parallel) garbage collector 
 default collector for server-class machines (multi-CPU Unix machines or any 64-bit JVM) 
 utilizes multiple threads for garbage collection to gain speed and minimize pauses 
 stops all application threads for both minor and full GC 
 -XX:+UseParallelGC enables multi-threaded collection of young generation and single-threaded 
www.luxoft.com 
old-generation collection/compaction 
 -XX:+UseParallelOldGC enables multi-threaded collection of young generation and multi-threaded 
old-generation collection/compaction 
Usage cases: 
 multi-CPU are available 
 large heap size and many object created/discarded
CMS (Concurrent Mark Sweep) collector 
 designed to eliminate long pauses associated with full GC cycles 
 stops all application threads during minor GC 
 uses different algorithm to collect young generation (-XX:+UseParNewGC) 
 uses one or more background threads to periodically scan through the old generation and discard 
unused objects. This makes CMS a low-paused collector 
 do not perform any compaction 
 in case of CPU unavailability and/or heap fragmentation – fallback to serial collector 
 by default does not collect permgen 
Usage cases: 
 low pause requirement and available CPU resources 
 in case of single-CPU machine can be used with -XX:+CMSIncrementalMode (deprecated in Java 
8) 
www.luxoft.com
G1 (Garbage First) garbage collector 
 designed to process large heaps (more than 4 Gb) with minimal pauses 
 divides the heap into separate regions 
 performs incremental compaction of old generation by copying data between 
regions 
www.luxoft.com
G1 (Garbage First) garbage collector 
www.luxoft.com
Summary (choosing GC algorithm) 
 Serial GC is best only for application with heap <= 100 Mb 
 Batch jobs which consume all available CPUs will get better performance 
with concurrent collector 
 Batch jobs which DON’T consume all CPUs could get better performance 
with throughput collector 
 When measuring response time the choice between throughput and 
concurrent collectors depends on CPU availability 
 Most of the time CMS should overperform G1 for heaps < 4 Gb 
 For large heaps G1 is better because of the way it can divide work between 
different threads and heap regions 
www.luxoft.com
www.luxoft.com
Sizing the heap 
 Too small heap -> too much time spent in GC 
 Main rule – never to specify heap more than the amount of available physical 
memory 
 -Xms – initial heap size 
 -Xmx – maximum heap size 
www.luxoft.com
Sizing the Generations 
 -XX:NewRatio=N – sets the ration of young generation to old 
 -XX:NewSize=N – sets the size of young generation 
 -XX:MaxNewSize=N – maximum size for young generation 
www.luxoft.com
Sizing Permgen and Metaspace 
Java 7: 
 -XX:PermSize=N 
 -XX:MaxPermSize=N 
Java 8: 
 -XX:MetaspaceSize=N 
 -XX:MaxMetaspaceSize=N 
www.luxoft.com
Adaptive Sizing 
JVM can try to find optimal performance according to its policies and configuration 
 Adaptive sizing controls how the JVM alters the ratio of young generation to old 
 Adjusting generation sizes is base on GC algorithms attempts to meet their pause goals 
 Adaptive tuning can be disabled for small performance boost (usually not recommended) 
 Command line argument differs for different GC algorithms. For, example for throughput collector: 
-XX:+UseAdaptiveSizePolicy – whether to use adaptive policy (true by default) 
-XX:MaxGCPauseMillis=nnn – maximal GC pause we can tolerate 
-XX:GCTimeRatio=nnn - hint to the virtual machine that it's desirable that not more than 1 / (1 + nnn) of the 
application execution time be spent in the collector 
www.luxoft.com
THANK YOU 
www.luxoft.com

Contenu connexe

Tendances

JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection Tuning
Kai Koenig
 
OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?
ScyllaDB
 

Tendances (20)

Taming Java Garbage Collector
Taming Java Garbage CollectorTaming Java Garbage Collector
Taming Java Garbage Collector
 
Scaling Apache Pulsar to 10 Petabytes/Day
Scaling Apache Pulsar to 10 Petabytes/DayScaling Apache Pulsar to 10 Petabytes/Day
Scaling Apache Pulsar to 10 Petabytes/Day
 
Revisão: Forwarding Metamorphosis: Fast Programmable Match-Action Processing ...
Revisão: Forwarding Metamorphosis: Fast Programmable Match-Action Processing ...Revisão: Forwarding Metamorphosis: Fast Programmable Match-Action Processing ...
Revisão: Forwarding Metamorphosis: Fast Programmable Match-Action Processing ...
 
Health Check Your DB2 UDB For Z/OS System
Health Check Your DB2 UDB For Z/OS SystemHealth Check Your DB2 UDB For Z/OS System
Health Check Your DB2 UDB For Z/OS System
 
Distributed scheduler hell (MicroXChg 2017 Berlin)
Distributed scheduler hell (MicroXChg 2017 Berlin)Distributed scheduler hell (MicroXChg 2017 Berlin)
Distributed scheduler hell (MicroXChg 2017 Berlin)
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVM
 
Taming The JVM
Taming The JVMTaming The JVM
Taming The JVM
 
Tools for Metaspace
Tools for MetaspaceTools for Metaspace
Tools for Metaspace
 
HotSpot JVM Tuning
HotSpot JVM TuningHotSpot JVM Tuning
HotSpot JVM Tuning
 
DB Latency Using DRAM + PMem in App Direct & Memory Modes
DB Latency Using DRAM + PMem in App Direct & Memory ModesDB Latency Using DRAM + PMem in App Direct & Memory Modes
DB Latency Using DRAM + PMem in App Direct & Memory Modes
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocators
 
JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection Tuning
 
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 InstanceExtreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
 
Continuous Go Profiling & Observability
Continuous Go Profiling & ObservabilityContinuous Go Profiling & Observability
Continuous Go Profiling & Observability
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
 
Jvm gc那点事
Jvm gc那点事Jvm gc那点事
Jvm gc那点事
 
OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?OSNoise Tracer: Who Is Stealing My CPU Time?
OSNoise Tracer: Who Is Stealing My CPU Time?
 
Data Structures for High Resolution, Real-time Telemetry at Scale
Data Structures for High Resolution, Real-time Telemetry at ScaleData Structures for High Resolution, Real-time Telemetry at Scale
Data Structures for High Resolution, Real-time Telemetry at Scale
 
CRAMM: Virtual Memory Support for Garbage-Collected Applications
CRAMM: Virtual Memory Support for Garbage-Collected ApplicationsCRAMM: Virtual Memory Support for Garbage-Collected Applications
CRAMM: Virtual Memory Support for Garbage-Collected Applications
 
Where Did All These Cycles Go?
Where Did All These Cycles Go?Where Did All These Cycles Go?
Where Did All These Cycles Go?
 

En vedette (10)

CTG-AnnualReport-2014_LR
CTG-AnnualReport-2014_LRCTG-AnnualReport-2014_LR
CTG-AnnualReport-2014_LR
 
PLANO DE ENSINO 2014.2 (1).pdf
PLANO DE ENSINO 2014.2 (1).pdfPLANO DE ENSINO 2014.2 (1).pdf
PLANO DE ENSINO 2014.2 (1).pdf
 
M Jouni_Achievments report
M Jouni_Achievments reportM Jouni_Achievments report
M Jouni_Achievments report
 
Presentación1festival
Presentación1festivalPresentación1festival
Presentación1festival
 
Lessons and Challenges from Mining Retail E-Commerce Data
Lessons and Challenges from Mining Retail E-Commerce DataLessons and Challenges from Mining Retail E-Commerce Data
Lessons and Challenges from Mining Retail E-Commerce Data
 
Il bosco
Il boscoIl bosco
Il bosco
 
PECB Infographic: Information Security Incident Response Process Model
PECB Infographic: Information Security Incident Response Process Model PECB Infographic: Information Security Incident Response Process Model
PECB Infographic: Information Security Incident Response Process Model
 
Ganglios y nervios cervicales veterinaria
Ganglios y nervios cervicales veterinariaGanglios y nervios cervicales veterinaria
Ganglios y nervios cervicales veterinaria
 
Fissura lábio palatina
Fissura lábio palatina Fissura lábio palatina
Fissura lábio palatina
 
Vida y obra
Vida y obra Vida y obra
Vida y obra
 

Similaire à Вячеслав Блинов «Java Garbage Collection: A Performance Impact»

Similaire à Вячеслав Блинов «Java Garbage Collection: A Performance Impact» (20)

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
 
Jvm Architecture
Jvm ArchitectureJvm Architecture
Jvm Architecture
 
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory UsageChoosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
 
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...
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUG
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1
 
JVM Magic
JVM MagicJVM Magic
JVM Magic
 
7-JVM-arguments-JaxLondon-2023.pptx
7-JVM-arguments-JaxLondon-2023.pptx7-JVM-arguments-JaxLondon-2023.pptx
7-JVM-arguments-JaxLondon-2023.pptx
 
OpenDS_Jazoon2010
OpenDS_Jazoon2010OpenDS_Jazoon2010
OpenDS_Jazoon2010
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
7 jvm-arguments-Confoo
7 jvm-arguments-Confoo7 jvm-arguments-Confoo
7 jvm-arguments-Confoo
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
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
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on Kubernetes
 
weblogic perfomence tuning
weblogic perfomence tuningweblogic perfomence tuning
weblogic perfomence tuning
 

Plus de Anna Shymchenko

Plus de Anna Shymchenko (20)

Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "
 
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
 
Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"
 
Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++" Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++"
 
Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club”
Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club” Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club”
Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club”
 
Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"
 
Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"
Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"
Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"
 
Денис Прокопюк: “JMX in Java EE applications”
Денис Прокопюк: “JMX in Java EE applications”Денис Прокопюк: “JMX in Java EE applications”
Денис Прокопюк: “JMX in Java EE applications”
 
Роман Яворский "Introduction to DevOps"
Роман Яворский "Introduction to DevOps"Роман Яворский "Introduction to DevOps"
Роман Яворский "Introduction to DevOps"
 
Максим Сабарня “NoSQL: Not only SQL in developer’s life”
Максим Сабарня “NoSQL: Not only SQL in developer’s life” Максим Сабарня “NoSQL: Not only SQL in developer’s life”
Максим Сабарня “NoSQL: Not only SQL in developer’s life”
 
Андрей Лисниченко "SQL Injection"
Андрей Лисниченко "SQL Injection"Андрей Лисниченко "SQL Injection"
Андрей Лисниченко "SQL Injection"
 
Светлана Мухина "Metrics on agile projects"
Светлана Мухина "Metrics on agile projects"Светлана Мухина "Metrics on agile projects"
Светлана Мухина "Metrics on agile projects"
 
Андрей Слободяник "Test driven development using mockito"
Андрей Слободяник "Test driven development using mockito"Андрей Слободяник "Test driven development using mockito"
Андрей Слободяник "Test driven development using mockito"
 
Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"
 
Даурен Муса “IBM WebSphere - expensive but effective”
Даурен Муса “IBM WebSphere - expensive but effective” Даурен Муса “IBM WebSphere - expensive but effective”
Даурен Муса “IBM WebSphere - expensive but effective”
 
Александр Пашинский "Reinventing Design Patterns with Java 8"
Александр Пашинский "Reinventing Design Patterns with Java 8"Александр Пашинский "Reinventing Design Patterns with Java 8"
Александр Пашинский "Reinventing Design Patterns with Java 8"
 
Евгений Капинос "Advanced JPA (Java Persistent API)"
Евгений Капинос "Advanced JPA (Java Persistent API)"Евгений Капинос "Advanced JPA (Java Persistent API)"
Евгений Капинос "Advanced JPA (Java Persistent API)"
 
Event-driven architecture with Java technology stack
Event-driven architecture with Java technology stackEvent-driven architecture with Java technology stack
Event-driven architecture with Java technology stack
 
Do we need SOLID principles during software development?
Do we need SOLID principles during software development?Do we need SOLID principles during software development?
Do we need SOLID principles during software development?
 
Guava - Elements of Functional Programming
Guava - Elements of Functional Programming Guava - Elements of Functional Programming
Guava - Elements of Functional Programming
 

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Dernier (20)

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
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-...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.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 🔝✔️✔️
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 

Вячеслав Блинов «Java Garbage Collection: A Performance Impact»

  • 1. Java Garbage Collection: A Performance Impact Blynov Viacheslav Lead Software Developer 24 November 2014 www.luxoft.com
  • 3. Introduction Agenda  Garbage Collection Overview  Java GC Algorithms  Basic GC Tuning www.luxoft.com
  • 5. GC Purpose Objects that are referenced are said to be live Objects that are no longer referenced are considered dead and termed garbage Garbage collector is responsible for:  allocating memory  ensuring that any referenced objects remain in memory  recovering memory used by objects that are no longer reachable from references in executing code www.luxoft.com
  • 7. GC performance impact  Collector needs computational resources (CPU cycles) to perform garbage collection  As garbage collection involves moving objects in memory a collector must ensure that no thread is using these objects www.luxoft.com The pauses when all application threads are stopped are called stop-the-world pauses These pauses generally have the greatest impact on the performance of an application, and minimizing those pauses is the key consideration when tuning GC.
  • 14. Summary  all GC algorithms divide the heap into old and young generation  all GC algorithm employ stop-the-world approach to clearing objects from young generation, which is usually a very quick operation www.luxoft.com
  • 16. “Client” and “Server” JVM types Depending on underlying hardware platform and version JVM can act as “client” of “server” VM. This affect the choice of JIT compiler and default GC algorithm.  “client” platform is usually 32-bit and has 1 CPU  “server” platform is usually 64-bit (but 32-bit is also possible) and has several CPUs www.luxoft.com
  • 17. GC Algorithms  Serial garbage collector (-XX:+UseSerialGC)  Throughput collector (-XX:+UseParallelGC , -XX:+UseParallelOldGC)  CMS collector (-XX:+UseConcMarkSweepGC, -XX:+UseParNewGC)  G1 collector (-XX:+UseG1GC) www.luxoft.com
  • 18. Serial garbage collector  default collector for client-class platforms (32-bit JVMs on Windows or single-processor www.luxoft.com machines)  uses single thread to process heap  stops all application threads for both minor and full GC Usage cases:  no low-pause requirements  “client-style” single-CPU environment  very small heap (few hundred MBs)  several JVMs running on single platform (number of JVM > number of available CPUs)
  • 19. Throughput (parallel) garbage collector  default collector for server-class machines (multi-CPU Unix machines or any 64-bit JVM)  utilizes multiple threads for garbage collection to gain speed and minimize pauses  stops all application threads for both minor and full GC  -XX:+UseParallelGC enables multi-threaded collection of young generation and single-threaded www.luxoft.com old-generation collection/compaction  -XX:+UseParallelOldGC enables multi-threaded collection of young generation and multi-threaded old-generation collection/compaction Usage cases:  multi-CPU are available  large heap size and many object created/discarded
  • 20. CMS (Concurrent Mark Sweep) collector  designed to eliminate long pauses associated with full GC cycles  stops all application threads during minor GC  uses different algorithm to collect young generation (-XX:+UseParNewGC)  uses one or more background threads to periodically scan through the old generation and discard unused objects. This makes CMS a low-paused collector  do not perform any compaction  in case of CPU unavailability and/or heap fragmentation – fallback to serial collector  by default does not collect permgen Usage cases:  low pause requirement and available CPU resources  in case of single-CPU machine can be used with -XX:+CMSIncrementalMode (deprecated in Java 8) www.luxoft.com
  • 21. G1 (Garbage First) garbage collector  designed to process large heaps (more than 4 Gb) with minimal pauses  divides the heap into separate regions  performs incremental compaction of old generation by copying data between regions www.luxoft.com
  • 22. G1 (Garbage First) garbage collector www.luxoft.com
  • 23. Summary (choosing GC algorithm)  Serial GC is best only for application with heap <= 100 Mb  Batch jobs which consume all available CPUs will get better performance with concurrent collector  Batch jobs which DON’T consume all CPUs could get better performance with throughput collector  When measuring response time the choice between throughput and concurrent collectors depends on CPU availability  Most of the time CMS should overperform G1 for heaps < 4 Gb  For large heaps G1 is better because of the way it can divide work between different threads and heap regions www.luxoft.com
  • 25. Sizing the heap  Too small heap -> too much time spent in GC  Main rule – never to specify heap more than the amount of available physical memory  -Xms – initial heap size  -Xmx – maximum heap size www.luxoft.com
  • 26. Sizing the Generations  -XX:NewRatio=N – sets the ration of young generation to old  -XX:NewSize=N – sets the size of young generation  -XX:MaxNewSize=N – maximum size for young generation www.luxoft.com
  • 27. Sizing Permgen and Metaspace Java 7:  -XX:PermSize=N  -XX:MaxPermSize=N Java 8:  -XX:MetaspaceSize=N  -XX:MaxMetaspaceSize=N www.luxoft.com
  • 28. Adaptive Sizing JVM can try to find optimal performance according to its policies and configuration  Adaptive sizing controls how the JVM alters the ratio of young generation to old  Adjusting generation sizes is base on GC algorithms attempts to meet their pause goals  Adaptive tuning can be disabled for small performance boost (usually not recommended)  Command line argument differs for different GC algorithms. For, example for throughput collector: -XX:+UseAdaptiveSizePolicy – whether to use adaptive policy (true by default) -XX:MaxGCPauseMillis=nnn – maximal GC pause we can tolerate -XX:GCTimeRatio=nnn - hint to the virtual machine that it's desirable that not more than 1 / (1 + nnn) of the application execution time be spent in the collector www.luxoft.com