SlideShare a Scribd company logo
Copyright 2016 Kirk Pepperdine
Moving to G1GC
Copyright 2016 Kirk Pepperdine
About me

- Write and speak about performance tuning

- Offer performance tuning services and training

- created jPDM, a performance tuning methodology

- Co-founder of jClarity

- building the first generation of performance
diagnostic engines

- Java Champion since 2006
Copyright 2016 Kirk Pepperdine
G1GC will the be the default collector in Java 9
What impact might this have on
your applications performance?
Copyright 2016 Kirk Pepperdine
Questions To Be Answered

- What does a Regional heap look like?

- How does the current G1GC algorithm work?

- How does performance compare to other collectors

- What are the tools we can use the to help us;

- engage in evidence based tuning

- develop strategies so GC doesn’t interfere with
with our application’s throughput

- tune our application to work better with the
collector
Copyright 2016 Kirk Pepperdine
Generational Garbage Collection

- Mark-Sweep Copy (evacuation) for Young

- eden and survivor spaces

- both serial and parallel implementations

- Mark-Sweep (in-place) for Old space

- Serial and Parallel with compaction

- (mostly) Concurrent Mark-Sweep

- incremential mode
Copyright 2016 Kirk Pepperdine
Why another collector

- Scalability

- pause time tends to be a function of heap size

- CMS is difficult to tune

- dozens of parameters some of which are very difficult
to understand how to use

- -XX:TLABWasteTargetPercent=????

- Completely unpredictable

- well, maybe but that is a different talk
Copyright 2016 Kirk Pepperdine
G1GC

- Designed to scale

- break the pause time heap size dependency

- Easier to tune (maybe)

- fewer configuration options

- Predictable

- offer pause time goals and have the collector tune it’s
self
Copyright 2016 Kirk Pepperdine
A G1GC heap is

- 1 large contigous reserved space

- specified with -mx

- split into ~2048 regions

- size is 1, 2, 4, 8, 16, 32, or 64m

eg. -mx10G,

Region size = 10240M/2048 = 5m

reduce to 4G

Number of regions = 10G/4m = 2560
Copyright 2016 Kirk Pepperdine
Regions

- Free regions are kept on a free region list

- When in use will be tagged as;

- Eden, Survivor, Old, or Humongous
Copyright 2016 Kirk Pepperdine
Allocation

- Free regions are kept on a free region list

- mutator threads acquire a region from region free list

- tag region as Eden

- allocate object into region

- when region is full, get a new regions from free list
Eden
Eden
Eden
Eden
Copyright 2016 Kirk Pepperdine
Humongous Allocation

- allocation is larger than 1/2 a regions size

- size of a regions defines what is humongous

- allocate into a humoungous region 

- created from a set of contigous regions
Eden
Eden
Eden
Eden
Humongous
Copyright 2016 Kirk Pepperdine
Garbage Collection Triggers

- Alloted number of Eden regions have been consumed

- Unable to satisfy a Humongous allocation

- regions fragmentation

- may lead to full collection

- Heap is full

- full collection

- Metaspace threshold is reached

- full discussion beyond the scope of this talk
Copyright 2016 Kirk Pepperdine
Garbage Collection

- Young Gen is Mark-Sweep

- Mostly Concurrent-Mark of Tenured

- initial-mark included with Young-Gen collection

- concurrent-root-region-scan

- concurrent-mark

- remark

- cleanup

- concurrent-cleanup

- Mixed is mark Young, sweep Young and some tenured
Copyright 2016 Kirk Pepperdine
Reclaiming Memory (detailed)

- Mark Sweep Copy (Evacuating) Garbage Collection

- Capture all mutator threads at a safepoint

- Complete RSet refinement

- Scan for GC Roots

- Trace all references from GC roots

- mark all data reached during tracing

- Copy all marked data into a “to space”

- Reset supporting structures

- Release all mutator threads
Copyright 2016 Kirk Pepperdine
RSet

- Track all external pointers to a region

- GC roots for the region

- Expensive to update

- mutations recored to a refinement
queue

- update delegated to refinement
threads
Copyright 2016 Kirk Pepperdine
RSet Refinement

- Refinement queue is divided into 4 regions

- White: no refinement threads are working

- Green: number of cards that can be processed
without exceeding 10% of pause time

- Yellow: all refinement threads are working to keep
up

- Red: Application threads are involved in refinement
Copyright 2016 Kirk Pepperdine
CSets

- Set of all regions to be swept

- Goal is to keep pauses under MaxGCPauseMillis

- controls the size of the CSet

- CSet contain

- all Young regions

- selected Old regions during mixed collections

- number / mixed GC ratio
Copyright 2016 Kirk Pepperdine
Heap after a Mark/Sweep

- all surviving objects are copied into (to) Survivor regions

- Eden and (from) Survivor regions are returned to free
regions list
Humoungous
Survivor
Copyright 2016 Kirk Pepperdine
Promotion to Old

- Data is promoted to old

- from survivor when it reaches tenuring threshold

- to prevent survivor from being overrun

- pre-emptive or reactive
Humongous
Survivor Old
Copyright 2016 Kirk Pepperdine
Parallel Phases

- external root scanning

- updating remembered sets

- scan remembered sets

- code root scanning

- object copy

- string dedup
Copyright 2016 Kirk Pepperdine
Serial Phases

- code root fixup

- code root migration

- clear CT

- choose CSet

- Reference processing

- redirty cards

- free CSet
Copyright 2016 Kirk Pepperdine
Starting a (mostly) Concurrent Cycle

- Scheduled when heap occupancy reaches 45%

- initial-mark runs inside a Young collection

- mark calculates livelyness

- used for CSet inclusion decisions
Eden
Eden
Eden
Eden
Humoungous Survivor
Survivor
Old
OldOld
Old
Old
Old
Old
Old OldOld
Old
Old
Old
Old
Old
Copyright 2016 Kirk Pepperdine
Flags (you want to use)

-XX:+UseG1GC

-mx4G

-XX:MaxGCPauseMillis=200

-Xloggc:gc.log

-XX:+PrintGCDetails

-XX:+PrintTenuringDistribution

-XX:+PrintReferenceGC"

-XX:+PrintGCApplicationStoppedTime

-XX:+PrintGCApplicationConcurrentTime"
Copyright 2016 Kirk Pepperdine
Flags (you might want to use)

-XX:G1HeapRegionSize=1

-XX:InitiatingHeapOccupancyPercent=45

-XX:+UnlockExperimentalVMOptions"

-XX:G1NewSizePercent=5

-XX:+UnlockDiagnosticVMOptions

-XX:+G1PrintRegionLivenessInfo

-XX:SurvivorRatio=6

-XX:MaxTenuringThreshold=15
Copyright 2016 Kirk Pepperdine
Flags (you should think twice about using)

-XX:G1MixedGCCountTarget=8

-XX:+UnlockExperimentalVMOptions"

-XX:G1MixedGCLiveThresholdPercent=85/65
Copyright 2016 Kirk Pepperdine
Flags (you should never use)

-XX:+UnlockExperimentalVMOptions"

-XX:G1OldCSetRegionThresholdPercent=10

-XX:G1MaxNewSizePercent=60

-XX:G1HeapWastePercent=10

-XX:G1RSetUpdatingPauseTimePercent=10
Copyright 2016 Kirk Pepperdine
Things that give the G1 grief

- RSet refinement

- too much overhead to put work on mutator thread

- affects application throughput

- high rates of mutation place pressure on RSet
refinement

- will affect Young parallel phase and remark times

- Object copy

- not much to say here (unfortunately)
Copyright 2016 Kirk Pepperdine
Things that give the G1 grief

- Humongous allocations

- definition controlled by region size

- bigger region yields bigger RSet refinement costs

- Floating garbage

- “dead” objects in other regions keep dead objects
alive

- negative impact on object copy costs

- more aggressive ripeness settings

- most costly collections
Copyright 2016 Kirk Pepperdine
Tuning Cassandra (benchmark)

- Out of the box tuned for using CMS

- exceptionally complex set of configurations

- Reconfigured

- to run G1

- given fixed unit of work which should ideally be
cleared in 15 minutes
Goal: Configure G1 to maximize MMU
Copyright 2016 Kirk Pepperdine
Cassandra throughput running @ 100% CPU
0
17500
35000
52500
70000
1 2 3 4 5 6 7 8 9 10 11 12
CMS
G1GC
Copyright 2016 Kirk Pepperdine
Run times
00:12:35
00:14:40
00:16:45
00:18:50
00:20:55
1 2 3 4 5 6 7 8 9 10 11
Copyright 2016 Kirk Pepperdine
Weak Generational Hypothesis
Rate
Time
Copyright 2016 Kirk Pepperdine
Performance Seminar
`
www.kodewerk.com
Java
Performance Tuning,
June
2-5, Chania
Greece

More Related Content

PPTX
Hadoop world g1_gc_forh_base_v4
YanpingWang
 
PDF
Moving to G1GC
Kirk Pepperdine
 
PPT
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Gurpreet Sachdeva
 
PPTX
G1 collector and tuning and Cassandra
Chris Lohfink
 
PPTX
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Monica Beckwith
 
PPTX
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Monica Beckwith
 
PPTX
G1GC
koji lin
 
PDF
-XX:+UseG1GC
Jakub Kubrynski
 
Hadoop world g1_gc_forh_base_v4
YanpingWang
 
Moving to G1GC
Kirk Pepperdine
 
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Gurpreet Sachdeva
 
G1 collector and tuning and Cassandra
Chris Lohfink
 
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Monica Beckwith
 
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Monica Beckwith
 
G1GC
koji lin
 
-XX:+UseG1GC
Jakub Kubrynski
 

What's hot (20)

PPTX
G1 Garbage Collector - Big Heaps and Low Pauses?
C2B2 Consulting
 
PDF
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
Monica Beckwith
 
PDF
GC Tuning Confessions Of A Performance Engineer
Monica Beckwith
 
PDF
Tuning Java for Big Data
Scott Seighman
 
PDF
Gclogs j1
Kirk Pepperdine
 
PDF
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
Monica Beckwith
 
PDF
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
Monica Beckwith
 
PDF
Garbage First Garbage Collector: Where the Rubber Meets the Road!
Monica Beckwith
 
PPTX
Storing Cassandra Metrics
Chris Lohfink
 
PDF
Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Monica Beckwith
 
PDF
Taming GC Pauses for Humongous Java Heaps in Spark Graph Computing-(Eric Kacz...
Spark Summit
 
PDF
GC Tuning Confessions Of A Performance Engineer - Improved :)
Monica Beckwith
 
PPTX
GoodFit: Multi-Resource Packing of Tasks with Dependencies
DataWorks Summit/Hadoop Summit
 
PPTX
Jvm tuning for low latency application & Cassandra
Quentin Ambard
 
PDF
Low pause GC in HotSpot
jClarity
 
PPTX
Jvm & Garbage collection tuning for low latencies application
Quentin Ambard
 
PDF
On heap cache vs off-heap cache
rgrebski
 
PDF
Basics of JVM Tuning
Vladislav Gangan
 
PDF
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Red Hat Developers
 
PPTX
Keynote: Apache HBase at Yahoo! Scale
HBaseCon
 
G1 Garbage Collector - Big Heaps and Low Pauses?
C2B2 Consulting
 
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
Monica Beckwith
 
GC Tuning Confessions Of A Performance Engineer
Monica Beckwith
 
Tuning Java for Big Data
Scott Seighman
 
Gclogs j1
Kirk Pepperdine
 
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
Monica Beckwith
 
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
Monica Beckwith
 
Garbage First Garbage Collector: Where the Rubber Meets the Road!
Monica Beckwith
 
Storing Cassandra Metrics
Chris Lohfink
 
Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Monica Beckwith
 
Taming GC Pauses for Humongous Java Heaps in Spark Graph Computing-(Eric Kacz...
Spark Summit
 
GC Tuning Confessions Of A Performance Engineer - Improved :)
Monica Beckwith
 
GoodFit: Multi-Resource Packing of Tasks with Dependencies
DataWorks Summit/Hadoop Summit
 
Jvm tuning for low latency application & Cassandra
Quentin Ambard
 
Low pause GC in HotSpot
jClarity
 
Jvm & Garbage collection tuning for low latencies application
Quentin Ambard
 
On heap cache vs off-heap cache
rgrebski
 
Basics of JVM Tuning
Vladislav Gangan
 
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Red Hat Developers
 
Keynote: Apache HBase at Yahoo! Scale
HBaseCon
 
Ad

Viewers also liked (6)

ODP
G1 Garbage Collector: Details and Tuning
Simone Bordet
 
PDF
Enabling Java in Latency-Sensitive Applications
Azul Systems Inc.
 
PPTX
Java7 Garbage Collector G1
Dmitry Buzdin
 
PDF
How to Become a Winner in the JVM Performance-Tuning Battle
Capgemini
 
PDF
Introduction of Java GC Tuning and Java Java Mission Control
Leon Chen
 
PDF
Solving Multi-tenancy and G1GC in Apache HBase
HBaseCon
 
G1 Garbage Collector: Details and Tuning
Simone Bordet
 
Enabling Java in Latency-Sensitive Applications
Azul Systems Inc.
 
Java7 Garbage Collector G1
Dmitry Buzdin
 
How to Become a Winner in the JVM Performance-Tuning Battle
Capgemini
 
Introduction of Java GC Tuning and Java Java Mission Control
Leon Chen
 
Solving Multi-tenancy and G1GC in Apache HBase
HBaseCon
 
Ad

Similar to Moving to g1 gc by Kirk Pepperdine. (20)

PDF
Tuning the g1gc
Kirk Pepperdine
 
PPTX
Comparative Performance Analysis of AWS EC2 Instance Types Commonly Used for ...
DataWorks Summit
 
PPTX
Hadoop performance optimization tips
Subhas Kumar Ghosh
 
PPTX
Pig on Tez - Low Latency ETL with Big Data
DataWorks Summit
 
PDF
Performance Analysis of Lattice QCD on GPUs in APGAS Programming Model
Koichi Shirahata
 
PDF
Apache Spark Best Practices Meetup Talk
Eren Avşaroğulları
 
PPTX
JVM memory management & Diagnostics
Dhaval Shah
 
PDF
MATLAB_BIg_Data_ds_Haddop_22032015
Asaf Ben Gal
 
PPT
Running Spark in Production
DataWorks Summit/Hadoop Summit
 
PPTX
Tuning tips for Apache Spark Jobs
Samir Bessalah
 
PPTX
JVM and OS Tuning for accelerating Spark application
Tatsuhiro Chiba
 
PPTX
Progress_190130
Hyo jeong Lee
 
PDF
Storm Users Group Real Time Hadoop
MapR Technologies
 
PDF
Storm users group real time hadoop
Ted Dunning
 
PPTX
Introduction to DPDK
Kernel TLV
 
PDF
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
Haim Yadid
 
PPTX
Explore big data at speed of thought with Spark 2.0 and Snappydata
Data Con LA
 
PPTX
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
DataStax
 
PDF
Spark performance tuning - Maksud Ibrahimov
Maksud Ibrahimov
 
PDF
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...
Databricks
 
Tuning the g1gc
Kirk Pepperdine
 
Comparative Performance Analysis of AWS EC2 Instance Types Commonly Used for ...
DataWorks Summit
 
Hadoop performance optimization tips
Subhas Kumar Ghosh
 
Pig on Tez - Low Latency ETL with Big Data
DataWorks Summit
 
Performance Analysis of Lattice QCD on GPUs in APGAS Programming Model
Koichi Shirahata
 
Apache Spark Best Practices Meetup Talk
Eren Avşaroğulları
 
JVM memory management & Diagnostics
Dhaval Shah
 
MATLAB_BIg_Data_ds_Haddop_22032015
Asaf Ben Gal
 
Running Spark in Production
DataWorks Summit/Hadoop Summit
 
Tuning tips for Apache Spark Jobs
Samir Bessalah
 
JVM and OS Tuning for accelerating Spark application
Tatsuhiro Chiba
 
Progress_190130
Hyo jeong Lee
 
Storm Users Group Real Time Hadoop
MapR Technologies
 
Storm users group real time hadoop
Ted Dunning
 
Introduction to DPDK
Kernel TLV
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
Haim Yadid
 
Explore big data at speed of thought with Spark 2.0 and Snappydata
Data Con LA
 
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
DataStax
 
Spark performance tuning - Maksud Ibrahimov
Maksud Ibrahimov
 
Strava Labs: Exploring a Billion Activity Dataset from Athletes with Apache S...
Databricks
 

More from J On The Beach (20)

PDF
Massively scalable ETL in real world applications: the hard way
J On The Beach
 
PPTX
Big Data On Data You Don’t Have
J On The Beach
 
PPTX
Acoustic Time Series in Industry 4.0: Improved Reliability and Cyber-Security...
J On The Beach
 
PDF
Pushing it to the edge in IoT
J On The Beach
 
PDF
Drinking from the firehose, with virtual streams and virtual actors
J On The Beach
 
PDF
How do we deploy? From Punched cards to Immutable server pattern
J On The Beach
 
PDF
Java, Turbocharged
J On The Beach
 
PDF
When Cloud Native meets the Financial Sector
J On The Beach
 
PDF
The big data Universe. Literally.
J On The Beach
 
PDF
Streaming to a New Jakarta EE
J On The Beach
 
PDF
The TIPPSS Imperative for IoT - Ensuring Trust, Identity, Privacy, Protection...
J On The Beach
 
PDF
Pushing AI to the Client with WebAssembly and Blazor
J On The Beach
 
PDF
Axon Server went RAFTing
J On The Beach
 
PDF
The Six Pitfalls of building a Microservices Architecture (and how to avoid t...
J On The Beach
 
PDF
Madaari : Ordering For The Monkeys
J On The Beach
 
PDF
Servers are doomed to fail
J On The Beach
 
PDF
Interaction Protocols: It's all about good manners
J On The Beach
 
PDF
A race of two compilers: GraalVM JIT versus HotSpot JIT C2. Which one offers ...
J On The Beach
 
PDF
Leadership at every level
J On The Beach
 
PDF
Machine Learning: The Bare Math Behind Libraries
J On The Beach
 
Massively scalable ETL in real world applications: the hard way
J On The Beach
 
Big Data On Data You Don’t Have
J On The Beach
 
Acoustic Time Series in Industry 4.0: Improved Reliability and Cyber-Security...
J On The Beach
 
Pushing it to the edge in IoT
J On The Beach
 
Drinking from the firehose, with virtual streams and virtual actors
J On The Beach
 
How do we deploy? From Punched cards to Immutable server pattern
J On The Beach
 
Java, Turbocharged
J On The Beach
 
When Cloud Native meets the Financial Sector
J On The Beach
 
The big data Universe. Literally.
J On The Beach
 
Streaming to a New Jakarta EE
J On The Beach
 
The TIPPSS Imperative for IoT - Ensuring Trust, Identity, Privacy, Protection...
J On The Beach
 
Pushing AI to the Client with WebAssembly and Blazor
J On The Beach
 
Axon Server went RAFTing
J On The Beach
 
The Six Pitfalls of building a Microservices Architecture (and how to avoid t...
J On The Beach
 
Madaari : Ordering For The Monkeys
J On The Beach
 
Servers are doomed to fail
J On The Beach
 
Interaction Protocols: It's all about good manners
J On The Beach
 
A race of two compilers: GraalVM JIT versus HotSpot JIT C2. Which one offers ...
J On The Beach
 
Leadership at every level
J On The Beach
 
Machine Learning: The Bare Math Behind Libraries
J On The Beach
 

Recently uploaded (20)

PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PDF
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
oapresentation.pptx
mehatdhavalrajubhai
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 

Moving to g1 gc by Kirk Pepperdine.

  • 1. Copyright 2016 Kirk Pepperdine Moving to G1GC
  • 2. Copyright 2016 Kirk Pepperdine About me - Write and speak about performance tuning - Offer performance tuning services and training - created jPDM, a performance tuning methodology - Co-founder of jClarity - building the first generation of performance diagnostic engines - Java Champion since 2006
  • 3. Copyright 2016 Kirk Pepperdine G1GC will the be the default collector in Java 9 What impact might this have on your applications performance?
  • 4. Copyright 2016 Kirk Pepperdine Questions To Be Answered - What does a Regional heap look like? - How does the current G1GC algorithm work? - How does performance compare to other collectors - What are the tools we can use the to help us; - engage in evidence based tuning - develop strategies so GC doesn’t interfere with with our application’s throughput - tune our application to work better with the collector
  • 5. Copyright 2016 Kirk Pepperdine Generational Garbage Collection - Mark-Sweep Copy (evacuation) for Young - eden and survivor spaces - both serial and parallel implementations - Mark-Sweep (in-place) for Old space - Serial and Parallel with compaction - (mostly) Concurrent Mark-Sweep - incremential mode
  • 6. Copyright 2016 Kirk Pepperdine Why another collector - Scalability - pause time tends to be a function of heap size - CMS is difficult to tune - dozens of parameters some of which are very difficult to understand how to use - -XX:TLABWasteTargetPercent=???? - Completely unpredictable - well, maybe but that is a different talk
  • 7. Copyright 2016 Kirk Pepperdine G1GC - Designed to scale - break the pause time heap size dependency - Easier to tune (maybe) - fewer configuration options - Predictable - offer pause time goals and have the collector tune it’s self
  • 8. Copyright 2016 Kirk Pepperdine A G1GC heap is - 1 large contigous reserved space - specified with -mx - split into ~2048 regions - size is 1, 2, 4, 8, 16, 32, or 64m eg. -mx10G, Region size = 10240M/2048 = 5m reduce to 4G Number of regions = 10G/4m = 2560
  • 9. Copyright 2016 Kirk Pepperdine Regions - Free regions are kept on a free region list - When in use will be tagged as; - Eden, Survivor, Old, or Humongous
  • 10. Copyright 2016 Kirk Pepperdine Allocation - Free regions are kept on a free region list - mutator threads acquire a region from region free list - tag region as Eden - allocate object into region - when region is full, get a new regions from free list Eden Eden Eden Eden
  • 11. Copyright 2016 Kirk Pepperdine Humongous Allocation - allocation is larger than 1/2 a regions size - size of a regions defines what is humongous - allocate into a humoungous region - created from a set of contigous regions Eden Eden Eden Eden Humongous
  • 12. Copyright 2016 Kirk Pepperdine Garbage Collection Triggers - Alloted number of Eden regions have been consumed - Unable to satisfy a Humongous allocation - regions fragmentation - may lead to full collection - Heap is full - full collection - Metaspace threshold is reached - full discussion beyond the scope of this talk
  • 13. Copyright 2016 Kirk Pepperdine Garbage Collection - Young Gen is Mark-Sweep - Mostly Concurrent-Mark of Tenured - initial-mark included with Young-Gen collection - concurrent-root-region-scan - concurrent-mark - remark - cleanup - concurrent-cleanup - Mixed is mark Young, sweep Young and some tenured
  • 14. Copyright 2016 Kirk Pepperdine Reclaiming Memory (detailed) - Mark Sweep Copy (Evacuating) Garbage Collection - Capture all mutator threads at a safepoint - Complete RSet refinement - Scan for GC Roots - Trace all references from GC roots - mark all data reached during tracing - Copy all marked data into a “to space” - Reset supporting structures - Release all mutator threads
  • 15. Copyright 2016 Kirk Pepperdine RSet - Track all external pointers to a region - GC roots for the region - Expensive to update - mutations recored to a refinement queue - update delegated to refinement threads
  • 16. Copyright 2016 Kirk Pepperdine RSet Refinement - Refinement queue is divided into 4 regions - White: no refinement threads are working - Green: number of cards that can be processed without exceeding 10% of pause time - Yellow: all refinement threads are working to keep up - Red: Application threads are involved in refinement
  • 17. Copyright 2016 Kirk Pepperdine CSets - Set of all regions to be swept - Goal is to keep pauses under MaxGCPauseMillis - controls the size of the CSet - CSet contain - all Young regions - selected Old regions during mixed collections - number / mixed GC ratio
  • 18. Copyright 2016 Kirk Pepperdine Heap after a Mark/Sweep - all surviving objects are copied into (to) Survivor regions - Eden and (from) Survivor regions are returned to free regions list Humoungous Survivor
  • 19. Copyright 2016 Kirk Pepperdine Promotion to Old - Data is promoted to old - from survivor when it reaches tenuring threshold - to prevent survivor from being overrun - pre-emptive or reactive Humongous Survivor Old
  • 20. Copyright 2016 Kirk Pepperdine Parallel Phases - external root scanning - updating remembered sets - scan remembered sets - code root scanning - object copy - string dedup
  • 21. Copyright 2016 Kirk Pepperdine Serial Phases - code root fixup - code root migration - clear CT - choose CSet - Reference processing - redirty cards - free CSet
  • 22. Copyright 2016 Kirk Pepperdine Starting a (mostly) Concurrent Cycle - Scheduled when heap occupancy reaches 45% - initial-mark runs inside a Young collection - mark calculates livelyness - used for CSet inclusion decisions Eden Eden Eden Eden Humoungous Survivor Survivor Old OldOld Old Old Old Old Old OldOld Old Old Old Old Old
  • 23. Copyright 2016 Kirk Pepperdine Flags (you want to use) -XX:+UseG1GC -mx4G -XX:MaxGCPauseMillis=200 -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:+PrintReferenceGC" -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime"
  • 24. Copyright 2016 Kirk Pepperdine Flags (you might want to use) -XX:G1HeapRegionSize=1 -XX:InitiatingHeapOccupancyPercent=45 -XX:+UnlockExperimentalVMOptions" -XX:G1NewSizePercent=5 -XX:+UnlockDiagnosticVMOptions -XX:+G1PrintRegionLivenessInfo -XX:SurvivorRatio=6 -XX:MaxTenuringThreshold=15
  • 25. Copyright 2016 Kirk Pepperdine Flags (you should think twice about using) -XX:G1MixedGCCountTarget=8 -XX:+UnlockExperimentalVMOptions" -XX:G1MixedGCLiveThresholdPercent=85/65
  • 26. Copyright 2016 Kirk Pepperdine Flags (you should never use) -XX:+UnlockExperimentalVMOptions" -XX:G1OldCSetRegionThresholdPercent=10 -XX:G1MaxNewSizePercent=60 -XX:G1HeapWastePercent=10 -XX:G1RSetUpdatingPauseTimePercent=10
  • 27. Copyright 2016 Kirk Pepperdine Things that give the G1 grief - RSet refinement - too much overhead to put work on mutator thread - affects application throughput - high rates of mutation place pressure on RSet refinement - will affect Young parallel phase and remark times - Object copy - not much to say here (unfortunately)
  • 28. Copyright 2016 Kirk Pepperdine Things that give the G1 grief - Humongous allocations - definition controlled by region size - bigger region yields bigger RSet refinement costs - Floating garbage - “dead” objects in other regions keep dead objects alive - negative impact on object copy costs - more aggressive ripeness settings - most costly collections
  • 29. Copyright 2016 Kirk Pepperdine Tuning Cassandra (benchmark) - Out of the box tuned for using CMS - exceptionally complex set of configurations - Reconfigured - to run G1 - given fixed unit of work which should ideally be cleared in 15 minutes Goal: Configure G1 to maximize MMU
  • 30. Copyright 2016 Kirk Pepperdine Cassandra throughput running @ 100% CPU 0 17500 35000 52500 70000 1 2 3 4 5 6 7 8 9 10 11 12 CMS G1GC
  • 31. Copyright 2016 Kirk Pepperdine Run times 00:12:35 00:14:40 00:16:45 00:18:50 00:20:55 1 2 3 4 5 6 7 8 9 10 11
  • 32. Copyright 2016 Kirk Pepperdine Weak Generational Hypothesis Rate Time
  • 33. Copyright 2016 Kirk Pepperdine Performance Seminar ` www.kodewerk.com Java Performance Tuning, June 2-5, Chania Greece