SlideShare a Scribd company logo
Copyright 2018 Kirk Pepperdine
TUNING G1GC
A GUIDE TO
Copyright 2018 Kirk Pepperdine
HOW TO TUNE THE G1GC
▸ Set -XX:+UseG1GC
▸ Set max heap size using -mx
▸default value is 1/4 of physical RAM
▸ Set pause time goal using -XX:MaxGCPauseMillis=200 (default value)
jClarity
Copyright 2018 Kirk Pepperdine
Questions?
jClarity
Copyright 2018 Kirk Pepperdine
jClarity
I lift, you grab. … Was that
concept just a little too complex?
Copyright 2018 Kirk Pepperdine
jClarity
If only it was
that easy!
Copyright 2018 Kirk Pepperdine
Questions?
jClarity
Copyright 2018 Kirk Pepperdine
jClarity
▸ Kirk Pepperdine
▸ Author of jPDM, a performance diagnostic model
▸ Author of the original Java Performance Tuning workshop
▸ Co-founded jClarity
▸ Building the smart generation of performance diagnostic tooling
▸ Bring predictability into the diagnostic process
▸ Co-founded JCrete
▸ The hottest unconference on the planet
▸ Java Champion(s)
OUR MARKETING SLIDE
Copyright 2018 Kirk Pepperdine
▸Models help us to
▸ understand how things work
▸ develop a cost model
▸Memory management consists of
▸ allocators
▸ mutators
▸ Garbage Collector
IMPORTANCE OF MODELS
jClarity
Copyright 2018 Kirk Pepperdine
▸Allocator/Mutator takes on all responsibility for managing memory
▸ unmanaged runtimes
▸Workload is shared between Allocator/Mutator and Garbage Collectors
▸ balance between allocation/mutation throughput and GC pause time
▸more work to GC equates to longer GC pause times
▸more work to allocator/mutators equates to reduces application throughput
▸ Lets develop an understanding so we can build a cost model
ALLOCATORS VS COLLECTORS
jClarity
Copyright 2018 Kirk Pepperdine
THINGS WE NEED
▸ Java Heap
▸Regions
▸ Mark-Sweep (copy)
▸Young generational collection
▸Tenured Mark
▸Mixed collection
▸ Supporting Data Structures
▸ Collection set (CSet)
▸ Remembered Set (RSet)
▸ RSet refinement queue
▸ Tuning G1GC
jClarity
Copyright 2018 Kirk Pepperdine
THE G1GC HEAP
jClarity
▸Reserved as a single contiguous
region at JVM startup
▸Divide into 2048 to 4095 regions
▸ heap size is specified with -mx
▸ regions size is one of 1, 2, 4, 8,
16, or 32m
▸-XX:G1HeapRegionSize=<n>
▸example for -mx10G
Region size = 10240M/2048
= 5m
Number of regions = 10G/4m
= 2560 regions
Copyright 2018 Kirk Pepperdine
G1GC ALLOCATION
jClarity
All regions are put into a free region list
Copyright 2018 Kirk Pepperdine
G1GC ALLOCATION
jClarity
Free Region List
Copyright 2018 Kirk Pepperdine
ERGONOMICS
jClarity
Free Region List
Regions
allotted
for Eden
Copyright 2018 Kirk Pepperdine
G1GC ALLOCATION
jClarity
Free Region List
MyDominObject mdo = new MyDomainObject
Take region from free list
Copyright 2018 Kirk Pepperdine
G1GC ALLOCATION
jClarity
Free Region List
MyDominObject mdo = new MyDomainObject
Label it as Eden
Copyright 2018 Kirk Pepperdine
G1GC ALLOCATION
jClarity
Free Region List
MyDominObject mdo = new MyDomainObject
allocate
Copyright 2018 Kirk Pepperdine
G1GC ALLOCATION
jClarity
Free Region List
Continue until
allotted Regions
are full
Copyright 2018 Kirk Pepperdine
G1GC ALLOCATION
jClarity
Free Region List
Allocation failure triggers Young Gen collection
Copyright 2018 Kirk Pepperdine
FORMING A CSET
jClarity
Free Region List
Allocation failure triggers Young Gen collection
CSet
Copyright 2018 Kirk Pepperdine
YOUNG COLLECTION
▸ Mark/Sweep (copy)
▸Mix of parallel and serial phases
jClarity
1. Place all young gen regions into a CSet
2. Calculate a root set for the CSet
3. Mark all live data in the CSet
4. Evacuate all live data to the ‘to’ space

The ‘to’ space regions allocated from the free region list
5. Place eden regions back on free list
6. Ergonomics recalculates number of regions to allocate to Eden
Copyright 2018 Kirk Pepperdine
G1GC SIZING
jClarity
Free Region List
Head of List
New allocation limit
-XX:G1MaxNewSizePercentage=60, -XX:G1NewSizePercentage=5
Survivor regions
Copyright 2018 Kirk Pepperdine
THE G1GC HEAP
Eden Regions
Unallocated Regions
Young
jClarity
Survivor Region
aka: to space
Copyright 2018 Kirk Pepperdine
TENURING
Young
jClarity
Survivor Region
aka: to space
Tenured Region
Eden Regions
Unallocated Regions
Copyright 2018 Kirk Pepperdine
YOUNG COLLECTION
▸ Mark/Sweep (copy)
▸Mix of parallel and serial phases
▸Place all young gen regions into a CSet
▸Calculation a root set for the CSet
▸Mark all live
▸Evacuate all live to survivor regions allocated from the free region list
▸Place eden regions back on free list
▸Ergonomics recalculates number of regions to allocate to Eden
jClarity
Time complexity!!!!
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
Metaspace
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
Metaspace
Compressed
Classspace
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
JNI
Metaspace
Compressed
Classspace
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
Stack FramesJNI
Metaspace
Compressed
Classspace
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
Code Cache
Stack FramesJNI
Metaspace
Compressed
Classspace
Copyright 2018 Kirk Pepperdine
GC ROOTS
jClarity
Code Cache
Stack FramesJNI
Metaspace
Compressed
Classspace
C0
L1
L2
L3
Cn
L1
L2…
…
…
…
CPU
Registers
Copyright 2018 Kirk Pepperdine
SCAN FOR ROOTS
▸ Multi-threaded but….
▸Each individual space can be managed by a single thread
▸Large collections can only be managed by a single thread
▸ Scan for root time will be the longest time for scanning any single space
▸Often scan for roots is linear to the size of tenured
▸ G1 avoids this by introducing a remembered set (RSet)
jClarity
Copyright 2018 Kirk Pepperdine
RSET
▸Each Young gen region has an RSet
▸ Tracks pointers from Tenured regions into target region
▸ Requires a write barrier
▸ Has an associated space complexity
▸Complex implemetation solves this
▸RSet maintenance costs are non-linear to size of the region
▸ Mutations place an unwanted burden on the mutator threads
jClarity
Copyright 2018 Kirk Pepperdine
RSET REFINEMENT QUEUE
No threads are working
Number of RSets that can be processed run
less than 10% of the pause time goal
All refinement threads are working
G1UpdatingPauseTimePercent > 10%
Application threads are involved in RSet refinement.
Slow mutation rates which acts as back pressure
jClarity
Copyright 2018 Kirk Pepperdine
[15.316s][info ][gc,start ] GC(0) Pause Young (G1 Evacuation Pause)
[15.316s][info ][gc,start ] GC(0) Pause Young (G1 Evacuation Pause)
[15.316s][info ][gc,task ] GC(0) Using 8 workers of 8 for evacuation
[15.322s][info ][gc,phases ] GC(0) Pre Evacuate Collection Set: 0.0ms
[15.322s][info ][gc,phases ] GC(0) Evacuate Collection Set: 4.9ms
[15.322s][info ][gc,phases ] GC(0) Post Evacuate Collection Set: 1.0ms
[15.322s][info ][gc,phases ] GC(0) Other: 0.2ms
[15.322s][info ][gc,heap ] GC(0) Eden regions: 24->0(150)
[15.322s][info ][gc,heap ] GC(0) Survivor regions: 0->3(3)
[15.322s][info ][gc,heap ] GC(0) Old regions: 0->2
[15.322s][info ][gc,heap ] GC(0) Humongous regions: 0->0
[15.322s][info ][gc,metaspace ] GC(0) Metaspace: 16151K->16151K(1064960K)
[15.322s][info ][gc ] GC(0) Pause Young (G1 Evacuation Pause) 24M->4M(256M) 6.183ms
[15.322s][info ][gc,cpu ] GC(0) User=0.04s Sys=0.00s Real=0.00s
YOUNG COLLECTION
jClarity
Copyright 2018 Kirk Pepperdine
[15.322s][info ][gc,phases ] GC(0) Pre Evacuate Collection Set: 0ms
[15.322s][debug][gc,phases ] GC(0) Choose Collection Set: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Humongous Register: 0.0ms
YOUNG COLLECTION
jClarity
Copyright 2018 Kirk Pepperdine
[15.322s][info ][gc,phases ] GC(0) Evacuate Collection Set: 4.9ms
[15.322s][debug][gc,phases ] GC(0) Ext Root Scanning (ms): Min: 0.3, Avg: 0.8, Max: 2.5, Diff: 2.2, Sum: 6.3, Workers: 8
[15.322s][debug][gc,phases ] GC(0) Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0, Workers: 8
[15.322s][debug][gc,phases ] GC(0) Processed Buffers: Min: 0, Avg: 0.0, Max: 0, Diff: 0, Sum: 0, Workers: 8
[15.322s][debug][gc,phases ] GC(0) Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0, Workers: 8
[15.322s][debug][gc,phases ] GC(0) Code Root Scanning (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 1.7, Workers: 8
[15.322s][debug][gc,phases ] GC(0) Object Copy (ms): Min: 1.8, Avg: 3.4, Max: 4.3, Diff: 2.5, Sum: 27.0, Workers: 8
[15.322s][debug][gc,phases ] GC(0) Termination (ms): Min: 0.0, Avg: 0.4, Max: 0.6, Diff: 0.6, Sum: 3.4, Workers: 8
[15.322s][debug][gc,phases ] GC(0) Termination Attempts: Min: 1, Avg: 17.4, Max: 34, Diff: 33, Sum: 139, Workers: 8
[15.322s][debug][gc,phases ] GC(0) GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1, Workers: 8
[15.322s][debug][gc,phases ] GC(0) GC Worker Total (ms): Min: 4.8, Avg: 4.8, Max: 4.8, Diff: 0.0, Sum: 38.6, Workers: 8
YOUNG COLLECTION
jClarity
Copyright 2018 Kirk Pepperdine
[15.322s][info ][gc,phases ] GC(0) Post Evacuate Collection Set: 1.0ms
[15.322s][debug][gc,phases ] GC(0) Code Roots Fixup: 0.1ms
[15.322s][debug][gc,phases ] GC(0) Preserve CM Refs: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Reference Processing: 0.7ms
[15.322s][debug][gc,phases ] GC(0) Clear Card Table: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Reference Enqueuing: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Merge Per-Thread State: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Code Roots Purge: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Redirty Cards: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Free Collection Set: 0.2ms
[15.322s][debug][gc,phases ] GC(0) Humongous Reclaim: 0.0ms
[15.322s][debug][gc,phases ] GC(0) Expand Heap After Collection: 0.0ms
YOUNG COLLECTION
jClarity
Copyright 2018 Kirk Pepperdine
[73.082s][info ][gc ] GC(263) Concurrent Cycle
[73.082s][info ][gc,marking ] GC(263) Concurrent Clear Claimed Marks
[73.082s][info ][gc,marking ] GC(263) Concurrent Clear Claimed Marks 0.018ms
[73.082s][info ][gc,marking ] GC(263) Concurrent Scan Root Regions
[73.084s][info ][gc,marking ] GC(263) Concurrent Scan Root Regions 2.325ms
[73.084s][info ][gc,marking ] GC(263) Concurrent Mark (73.084s)
[73.084s][info ][gc,marking ] GC(263) Concurrent Mark From Roots
[73.084s][info ][gc,task ] GC(263) Using 2 workers of 2 for marking
[73.138s][info ][gc,marking ] GC(263) Concurrent Mark From Roots 53.902ms
[73.138s][info ][gc,marking ] GC(263) Concurrent Mark (73.084s, 73.138s) 53.954ms
[73.139s][info ][gc,start ] GC(263) Pause Remark
[73.160s][info ][gc,stringtable] GC(263) Cleaned string and symbol table, strings: 7924 processed, 21 removed, symbols: 55530
processed, 17 removed
[73.160s][info ][gc ] GC(263) Pause Remark 211M->211M(256M) 21.685ms
[73.160s][info ][gc,cpu ] GC(263) User=0.03s Sys=0.00s Real=0.02s
[73.160s][info ][gc,marking ] GC(263) Concurrent Create Live Data
[73.168s][info ][gc,marking ] GC(263) Concurrent Create Live Data 8.089ms
[73.169s][info ][gc,start ] GC(263) Pause Cleanup
[73.169s][info ][gc ] GC(263) Pause Cleanup 223M->213M(256M) 0.271ms
[73.169s][info ][gc,cpu ] GC(263) User=0.00s Sys=0.00s Real=0.00s
[73.169s][info ][gc,marking ] GC(263) Concurrent Complete Cleanup
[73.169s][info ][gc,marking ] GC(263) Concurrent Complete Cleanup 0.013ms
[73.169s][info ][gc,marking ] GC(263) Concurrent Cleanup for Next Mark
[73.171s][info ][gc,marking ] GC(263) Concurrent Cleanup for Next Mark 1.646ms
[73.171s][info ][gc ] GC(263) Concurrent Cycle 89.437ms
TENURED COLLECTION
jClarity
Copyright 2018 Kirk Pepperdine
COLLECTING TENURED
▸ Triggered at IHOP=45%
▸ Tenured regions are marked
▸region liveliness is calculated by the mark
23.615: [GC pause (Metadata GC Threshold) (young) (initial-mark)
23.649: [GC concurrent-root-region-scan-start]
23.698: [GC concurrent-root-region-scan-end, 0.0484826 secs]
23.698: [GC concurrent-mark-start]
23.889: [GC concurrent-mark-end, 0.1907474 secs]
23.889: [GC remark 23.889: [Finalize Marking, 0.0002867 secs] 23.889: [GC ref-proc, 0.0001423 secs] 23.889:
[Unloading, 0.0094320 secs], 0.0123489 secs]
23.902: [GC cleanup 504M->500M(1024M), 0.0015885 secs]
23.903: [GC concurrent-cleanup-start]
23.903: [GC concurrent-cleanup-end, 0.0000172 secs]
jClarity
Copyright 2018 Kirk Pepperdine
BUILDING A CSET REVISITED
▸ CSet contains all eden and survivor regions
▸a mixed collection will add a subset of tenured regions to the CSet
▸ CSet size is controlled by
▸the pause time goal (200ms default)
▸minimum collection percentages (10%)
▸other factors
jClarity
Copyright 2018 Kirk Pepperdine
MARK AND CALCULATE LIVELINESS
Tenured regions
jClarity
Copyright 2018 Kirk Pepperdine
SORT BY LIVELINESS
jClarity
Copyright 2018 Kirk Pepperdine
SORT BY LIVELINESS
jClarity
free eligible for collection not eligible
-XX:G1MixedGCLiveThresholdPercent=85
Copyright 2018 Kirk Pepperdine
ELIGIBLE REGIONS
jClarity
Copyright 2018 Kirk Pepperdine
MIXED COLLECTION COUNT
jClarity
-XX:G1OldCSetRegionThresholdPercent=10
-XX:G1HeapWastePercent=10
mixed 1 mixed 2 mixed 3 mixed 8…
Copyright 2018 Kirk Pepperdine
HUMONGOUS ALLOCATIONS
Tenured
Young
jClarity
Tenured Region
Humungous Region (start)
Humungous Region (cont)
Survivor Region
aka: to space
Eden Region
Unallocated Region
Copyright 2018 Kirk Pepperdine
HUMONGOUS ALLOCATIONS
Humungous Region (start)
Humungous Region (cont)
jClarity
▸Allocation that is 1/2 the size of a region
▸Fragmented heaps may not have enough
space to satisfy an allocation
▸ dip into reserved space
▸ trigger a young gen collection with and
initial-mark
▸commit more regions to the heap
▸ worst case can trigger a Full GC
Copyright 2018 Kirk Pepperdine
RESERVED SPACE
Tenured Region
Humungous Region (start)
Humungous Region (cont)
Survivor Region
aka: to space
Eden Region
Unallocated Region
Tenured
Young
jClarity
Reserved
Copyright 2018 Kirk Pepperdine
SOMETHINGS GONE OFF
jClarity
Copyright 2018 Kirk Pepperdine
HOW TO GET A GC LOG
jClarity
-Xloggc:gc.log
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-XX:+PrintGCDateStamps
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintReferenceGC
-Xlog:gc*,gc+ref,gc+phases=debug,gc+age=debug,safepoint:file=gc.log
Copyright 2018 Kirk Pepperdine
jClarity
DON’T LIKE READING GC LOGS?
I’ve got
your back
Copyright 2018 Kirk Pepperdine
▸ JDK 9
▸ G1GC is default collector
▸ improve ability to determine important memory setting
▸ migrate GC logging to Unified logging
▸ JDK 10
▸ Parallel full GC
▸ JDK 11
▸ new perf counters for STW during concurrent collection
▸ adaptive parallel reference processing
▸ Adaptive scaling for threads
RELEASE NOTES
jClarity
Copyright 2018 Kirk Pepperdine
WHY IS IT TAKING SO LONG???
jClarity
Lets look at a GC Log using Censum
Copyright 2018 Kirk Pepperdine
CONTROLLING OBJECT COPY COSTS
volume of reachable objects
jClarity
Occupancy
Age
Copyright 2018 Kirk Pepperdine
TEXT
TITLE TEXT
▸ Body Level One
▸ Body Level Two
▸ Body Level Three
▸ Body Level Four
▸ Body Level Five
Java Performance Tuning Workshop
Send us a Java 11 GC log or
tweet about @jclarity
and #censum
and
receive a free Censum License

More Related Content

What's hot

from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Works
Zhen Wei
 
CDC Stream Processing with Apache Flink
CDC Stream Processing with Apache FlinkCDC Stream Processing with Apache Flink
CDC Stream Processing with Apache Flink
Timo Walther
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2
Sergey Petrunya
 
RxNetty vs Tomcat Performance Results
RxNetty vs Tomcat Performance ResultsRxNetty vs Tomcat Performance Results
RxNetty vs Tomcat Performance Results
Brendan Gregg
 
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
DongMin Choi
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on Databricks
Databricks
 
PostgreSQL: Advanced indexing
PostgreSQL: Advanced indexingPostgreSQL: Advanced indexing
PostgreSQL: Advanced indexing
Hans-Jürgen Schönig
 
GC free coding in @Java presented @Geecon
GC free coding in @Java presented @GeeconGC free coding in @Java presented @Geecon
GC free coding in @Java presented @Geecon
Peter Lawrey
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
Charles Nutter
 
Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High Availability
Colin Charles
 
Embedded Rust on ESP2 - Rust Linz
Embedded Rust on ESP2 - Rust LinzEmbedded Rust on ESP2 - Rust Linz
Embedded Rust on ESP2 - Rust Linz
Juraj Michálek
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
Wei-Ren Chen
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and Tuning
Simone Bordet
 
Let's Learn to Talk to GC Logs in Java 9
Let's Learn to Talk to GC Logs in Java 9Let's Learn to Talk to GC Logs in Java 9
Let's Learn to Talk to GC Logs in Java 9
Poonam Bajaj Parhar
 
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
내훈 정
 
Market and Promote Your Products in Japan with Crowdfunding
Market and Promote Your Products in Japan with CrowdfundingMarket and Promote Your Products in Japan with Crowdfunding
Market and Promote Your Products in Japan with Crowdfunding
Ryota Matsuzaki
 
Care and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst OptimizerCare and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst Optimizer
Databricks
 
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
내훈 정
 
Speed Up Uber's Presto with Alluxio
Speed Up Uber's Presto with AlluxioSpeed Up Uber's Presto with Alluxio
Speed Up Uber's Presto with Alluxio
Alluxio, Inc.
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
Haribabu Nandyal Padmanaban
 

What's hot (20)

from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Works
 
CDC Stream Processing with Apache Flink
CDC Stream Processing with Apache FlinkCDC Stream Processing with Apache Flink
CDC Stream Processing with Apache Flink
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2
 
RxNetty vs Tomcat Performance Results
RxNetty vs Tomcat Performance ResultsRxNetty vs Tomcat Performance Results
RxNetty vs Tomcat Performance Results
 
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on Databricks
 
PostgreSQL: Advanced indexing
PostgreSQL: Advanced indexingPostgreSQL: Advanced indexing
PostgreSQL: Advanced indexing
 
GC free coding in @Java presented @Geecon
GC free coding in @Java presented @GeeconGC free coding in @Java presented @Geecon
GC free coding in @Java presented @Geecon
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High Availability
 
Embedded Rust on ESP2 - Rust Linz
Embedded Rust on ESP2 - Rust LinzEmbedded Rust on ESP2 - Rust Linz
Embedded Rust on ESP2 - Rust Linz
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and Tuning
 
Let's Learn to Talk to GC Logs in Java 9
Let's Learn to Talk to GC Logs in Java 9Let's Learn to Talk to GC Logs in Java 9
Let's Learn to Talk to GC Logs in Java 9
 
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
 
Market and Promote Your Products in Japan with Crowdfunding
Market and Promote Your Products in Japan with CrowdfundingMarket and Promote Your Products in Japan with Crowdfunding
Market and Promote Your Products in Japan with Crowdfunding
 
Care and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst OptimizerCare and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst Optimizer
 
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
 
Speed Up Uber's Presto with Alluxio
Speed Up Uber's Presto with AlluxioSpeed Up Uber's Presto with Alluxio
Speed Up Uber's Presto with Alluxio
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 

Similar to Tuning the g1gc

Trouble with memory
Trouble with memoryTrouble with memory
Trouble with memory
Kirk Pepperdine
 
Moving to G1GC
Moving to G1GCMoving to G1GC
Moving to G1GC
Kirk Pepperdine
 
Integrating Vert.x
Integrating Vert.xIntegrating Vert.x
Integrating Vert.x
Kirk Pepperdine
 
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesA Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
Altinity Ltd
 
Gc algorithms
Gc algorithmsGc algorithms
Gc algorithms
Michał Warecki
 
Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.
J On The Beach
 
JVM memory management & Diagnostics
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & Diagnostics
Dhaval Shah
 
G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?
C2B2 Consulting
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
Data Con LA
 
Gclogs j1
Gclogs j1Gclogs j1
Gclogs j1
Kirk Pepperdine
 
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEODangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Altinity Ltd
 
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GCHadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Erik Krogen
 
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
 
JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection Tuning
Kai Koenig
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
Prem Kuppumani
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
Leon Chen
 
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidiaRAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidia
Mail.ru Group
 
Gpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaGpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cuda
Ferdinand Jamitzky
 
A G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptxA G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptx
Monica Beckwith
 
Slices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr BodnarSlices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr Bodnar
GlobalLogic Ukraine
 

Similar to Tuning the g1gc (20)

Trouble with memory
Trouble with memoryTrouble with memory
Trouble with memory
 
Moving to G1GC
Moving to G1GCMoving to G1GC
Moving to G1GC
 
Integrating Vert.x
Integrating Vert.xIntegrating Vert.x
Integrating Vert.x
 
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesA Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
 
Gc algorithms
Gc algorithmsGc algorithms
Gc algorithms
 
Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.
 
JVM memory management & Diagnostics
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & Diagnostics
 
G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Data Provenance Support in...
 
Gclogs j1
Gclogs j1Gclogs j1
Gclogs j1
 
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEODangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
 
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GCHadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
 
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
 
JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection Tuning
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
 
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidiaRAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidia
 
Gpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaGpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cuda
 
A G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptxA G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptx
 
Slices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr BodnarSlices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr Bodnar
 

Recently uploaded

Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 

Recently uploaded (20)

Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 

Tuning the g1gc

  • 1. Copyright 2018 Kirk Pepperdine TUNING G1GC A GUIDE TO
  • 2. Copyright 2018 Kirk Pepperdine HOW TO TUNE THE G1GC ▸ Set -XX:+UseG1GC ▸ Set max heap size using -mx ▸default value is 1/4 of physical RAM ▸ Set pause time goal using -XX:MaxGCPauseMillis=200 (default value) jClarity
  • 3. Copyright 2018 Kirk Pepperdine Questions? jClarity
  • 4. Copyright 2018 Kirk Pepperdine jClarity I lift, you grab. … Was that concept just a little too complex?
  • 5. Copyright 2018 Kirk Pepperdine jClarity If only it was that easy!
  • 6. Copyright 2018 Kirk Pepperdine Questions? jClarity
  • 7. Copyright 2018 Kirk Pepperdine jClarity ▸ Kirk Pepperdine ▸ Author of jPDM, a performance diagnostic model ▸ Author of the original Java Performance Tuning workshop ▸ Co-founded jClarity ▸ Building the smart generation of performance diagnostic tooling ▸ Bring predictability into the diagnostic process ▸ Co-founded JCrete ▸ The hottest unconference on the planet ▸ Java Champion(s) OUR MARKETING SLIDE
  • 8. Copyright 2018 Kirk Pepperdine ▸Models help us to ▸ understand how things work ▸ develop a cost model ▸Memory management consists of ▸ allocators ▸ mutators ▸ Garbage Collector IMPORTANCE OF MODELS jClarity
  • 9. Copyright 2018 Kirk Pepperdine ▸Allocator/Mutator takes on all responsibility for managing memory ▸ unmanaged runtimes ▸Workload is shared between Allocator/Mutator and Garbage Collectors ▸ balance between allocation/mutation throughput and GC pause time ▸more work to GC equates to longer GC pause times ▸more work to allocator/mutators equates to reduces application throughput ▸ Lets develop an understanding so we can build a cost model ALLOCATORS VS COLLECTORS jClarity
  • 10. Copyright 2018 Kirk Pepperdine THINGS WE NEED ▸ Java Heap ▸Regions ▸ Mark-Sweep (copy) ▸Young generational collection ▸Tenured Mark ▸Mixed collection ▸ Supporting Data Structures ▸ Collection set (CSet) ▸ Remembered Set (RSet) ▸ RSet refinement queue ▸ Tuning G1GC jClarity
  • 11. Copyright 2018 Kirk Pepperdine THE G1GC HEAP jClarity ▸Reserved as a single contiguous region at JVM startup ▸Divide into 2048 to 4095 regions ▸ heap size is specified with -mx ▸ regions size is one of 1, 2, 4, 8, 16, or 32m ▸-XX:G1HeapRegionSize=<n> ▸example for -mx10G Region size = 10240M/2048 = 5m Number of regions = 10G/4m = 2560 regions
  • 12. Copyright 2018 Kirk Pepperdine G1GC ALLOCATION jClarity All regions are put into a free region list
  • 13. Copyright 2018 Kirk Pepperdine G1GC ALLOCATION jClarity Free Region List
  • 14. Copyright 2018 Kirk Pepperdine ERGONOMICS jClarity Free Region List Regions allotted for Eden
  • 15. Copyright 2018 Kirk Pepperdine G1GC ALLOCATION jClarity Free Region List MyDominObject mdo = new MyDomainObject Take region from free list
  • 16. Copyright 2018 Kirk Pepperdine G1GC ALLOCATION jClarity Free Region List MyDominObject mdo = new MyDomainObject Label it as Eden
  • 17. Copyright 2018 Kirk Pepperdine G1GC ALLOCATION jClarity Free Region List MyDominObject mdo = new MyDomainObject allocate
  • 18. Copyright 2018 Kirk Pepperdine G1GC ALLOCATION jClarity Free Region List Continue until allotted Regions are full
  • 19. Copyright 2018 Kirk Pepperdine G1GC ALLOCATION jClarity Free Region List Allocation failure triggers Young Gen collection
  • 20. Copyright 2018 Kirk Pepperdine FORMING A CSET jClarity Free Region List Allocation failure triggers Young Gen collection CSet
  • 21. Copyright 2018 Kirk Pepperdine YOUNG COLLECTION ▸ Mark/Sweep (copy) ▸Mix of parallel and serial phases jClarity 1. Place all young gen regions into a CSet 2. Calculate a root set for the CSet 3. Mark all live data in the CSet 4. Evacuate all live data to the ‘to’ space
 The ‘to’ space regions allocated from the free region list 5. Place eden regions back on free list 6. Ergonomics recalculates number of regions to allocate to Eden
  • 22. Copyright 2018 Kirk Pepperdine G1GC SIZING jClarity Free Region List Head of List New allocation limit -XX:G1MaxNewSizePercentage=60, -XX:G1NewSizePercentage=5 Survivor regions
  • 23. Copyright 2018 Kirk Pepperdine THE G1GC HEAP Eden Regions Unallocated Regions Young jClarity Survivor Region aka: to space
  • 24. Copyright 2018 Kirk Pepperdine TENURING Young jClarity Survivor Region aka: to space Tenured Region Eden Regions Unallocated Regions
  • 25. Copyright 2018 Kirk Pepperdine YOUNG COLLECTION ▸ Mark/Sweep (copy) ▸Mix of parallel and serial phases ▸Place all young gen regions into a CSet ▸Calculation a root set for the CSet ▸Mark all live ▸Evacuate all live to survivor regions allocated from the free region list ▸Place eden regions back on free list ▸Ergonomics recalculates number of regions to allocate to Eden jClarity Time complexity!!!!
  • 26. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity
  • 27. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity
  • 28. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity Metaspace
  • 29. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity Metaspace Compressed Classspace
  • 30. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity JNI Metaspace Compressed Classspace
  • 31. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity Stack FramesJNI Metaspace Compressed Classspace
  • 32. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity Code Cache Stack FramesJNI Metaspace Compressed Classspace
  • 33. Copyright 2018 Kirk Pepperdine GC ROOTS jClarity Code Cache Stack FramesJNI Metaspace Compressed Classspace C0 L1 L2 L3 Cn L1 L2… … … … CPU Registers
  • 34. Copyright 2018 Kirk Pepperdine SCAN FOR ROOTS ▸ Multi-threaded but…. ▸Each individual space can be managed by a single thread ▸Large collections can only be managed by a single thread ▸ Scan for root time will be the longest time for scanning any single space ▸Often scan for roots is linear to the size of tenured ▸ G1 avoids this by introducing a remembered set (RSet) jClarity
  • 35. Copyright 2018 Kirk Pepperdine RSET ▸Each Young gen region has an RSet ▸ Tracks pointers from Tenured regions into target region ▸ Requires a write barrier ▸ Has an associated space complexity ▸Complex implemetation solves this ▸RSet maintenance costs are non-linear to size of the region ▸ Mutations place an unwanted burden on the mutator threads jClarity
  • 36. Copyright 2018 Kirk Pepperdine RSET REFINEMENT QUEUE No threads are working Number of RSets that can be processed run less than 10% of the pause time goal All refinement threads are working G1UpdatingPauseTimePercent > 10% Application threads are involved in RSet refinement. Slow mutation rates which acts as back pressure jClarity
  • 37. Copyright 2018 Kirk Pepperdine [15.316s][info ][gc,start ] GC(0) Pause Young (G1 Evacuation Pause) [15.316s][info ][gc,start ] GC(0) Pause Young (G1 Evacuation Pause) [15.316s][info ][gc,task ] GC(0) Using 8 workers of 8 for evacuation [15.322s][info ][gc,phases ] GC(0) Pre Evacuate Collection Set: 0.0ms [15.322s][info ][gc,phases ] GC(0) Evacuate Collection Set: 4.9ms [15.322s][info ][gc,phases ] GC(0) Post Evacuate Collection Set: 1.0ms [15.322s][info ][gc,phases ] GC(0) Other: 0.2ms [15.322s][info ][gc,heap ] GC(0) Eden regions: 24->0(150) [15.322s][info ][gc,heap ] GC(0) Survivor regions: 0->3(3) [15.322s][info ][gc,heap ] GC(0) Old regions: 0->2 [15.322s][info ][gc,heap ] GC(0) Humongous regions: 0->0 [15.322s][info ][gc,metaspace ] GC(0) Metaspace: 16151K->16151K(1064960K) [15.322s][info ][gc ] GC(0) Pause Young (G1 Evacuation Pause) 24M->4M(256M) 6.183ms [15.322s][info ][gc,cpu ] GC(0) User=0.04s Sys=0.00s Real=0.00s YOUNG COLLECTION jClarity
  • 38. Copyright 2018 Kirk Pepperdine [15.322s][info ][gc,phases ] GC(0) Pre Evacuate Collection Set: 0ms [15.322s][debug][gc,phases ] GC(0) Choose Collection Set: 0.0ms [15.322s][debug][gc,phases ] GC(0) Humongous Register: 0.0ms YOUNG COLLECTION jClarity
  • 39. Copyright 2018 Kirk Pepperdine [15.322s][info ][gc,phases ] GC(0) Evacuate Collection Set: 4.9ms [15.322s][debug][gc,phases ] GC(0) Ext Root Scanning (ms): Min: 0.3, Avg: 0.8, Max: 2.5, Diff: 2.2, Sum: 6.3, Workers: 8 [15.322s][debug][gc,phases ] GC(0) Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0, Workers: 8 [15.322s][debug][gc,phases ] GC(0) Processed Buffers: Min: 0, Avg: 0.0, Max: 0, Diff: 0, Sum: 0, Workers: 8 [15.322s][debug][gc,phases ] GC(0) Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0, Workers: 8 [15.322s][debug][gc,phases ] GC(0) Code Root Scanning (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 1.7, Workers: 8 [15.322s][debug][gc,phases ] GC(0) Object Copy (ms): Min: 1.8, Avg: 3.4, Max: 4.3, Diff: 2.5, Sum: 27.0, Workers: 8 [15.322s][debug][gc,phases ] GC(0) Termination (ms): Min: 0.0, Avg: 0.4, Max: 0.6, Diff: 0.6, Sum: 3.4, Workers: 8 [15.322s][debug][gc,phases ] GC(0) Termination Attempts: Min: 1, Avg: 17.4, Max: 34, Diff: 33, Sum: 139, Workers: 8 [15.322s][debug][gc,phases ] GC(0) GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1, Workers: 8 [15.322s][debug][gc,phases ] GC(0) GC Worker Total (ms): Min: 4.8, Avg: 4.8, Max: 4.8, Diff: 0.0, Sum: 38.6, Workers: 8 YOUNG COLLECTION jClarity
  • 40. Copyright 2018 Kirk Pepperdine [15.322s][info ][gc,phases ] GC(0) Post Evacuate Collection Set: 1.0ms [15.322s][debug][gc,phases ] GC(0) Code Roots Fixup: 0.1ms [15.322s][debug][gc,phases ] GC(0) Preserve CM Refs: 0.0ms [15.322s][debug][gc,phases ] GC(0) Reference Processing: 0.7ms [15.322s][debug][gc,phases ] GC(0) Clear Card Table: 0.0ms [15.322s][debug][gc,phases ] GC(0) Reference Enqueuing: 0.0ms [15.322s][debug][gc,phases ] GC(0) Merge Per-Thread State: 0.0ms [15.322s][debug][gc,phases ] GC(0) Code Roots Purge: 0.0ms [15.322s][debug][gc,phases ] GC(0) Redirty Cards: 0.0ms [15.322s][debug][gc,phases ] GC(0) Free Collection Set: 0.2ms [15.322s][debug][gc,phases ] GC(0) Humongous Reclaim: 0.0ms [15.322s][debug][gc,phases ] GC(0) Expand Heap After Collection: 0.0ms YOUNG COLLECTION jClarity
  • 41. Copyright 2018 Kirk Pepperdine [73.082s][info ][gc ] GC(263) Concurrent Cycle [73.082s][info ][gc,marking ] GC(263) Concurrent Clear Claimed Marks [73.082s][info ][gc,marking ] GC(263) Concurrent Clear Claimed Marks 0.018ms [73.082s][info ][gc,marking ] GC(263) Concurrent Scan Root Regions [73.084s][info ][gc,marking ] GC(263) Concurrent Scan Root Regions 2.325ms [73.084s][info ][gc,marking ] GC(263) Concurrent Mark (73.084s) [73.084s][info ][gc,marking ] GC(263) Concurrent Mark From Roots [73.084s][info ][gc,task ] GC(263) Using 2 workers of 2 for marking [73.138s][info ][gc,marking ] GC(263) Concurrent Mark From Roots 53.902ms [73.138s][info ][gc,marking ] GC(263) Concurrent Mark (73.084s, 73.138s) 53.954ms [73.139s][info ][gc,start ] GC(263) Pause Remark [73.160s][info ][gc,stringtable] GC(263) Cleaned string and symbol table, strings: 7924 processed, 21 removed, symbols: 55530 processed, 17 removed [73.160s][info ][gc ] GC(263) Pause Remark 211M->211M(256M) 21.685ms [73.160s][info ][gc,cpu ] GC(263) User=0.03s Sys=0.00s Real=0.02s [73.160s][info ][gc,marking ] GC(263) Concurrent Create Live Data [73.168s][info ][gc,marking ] GC(263) Concurrent Create Live Data 8.089ms [73.169s][info ][gc,start ] GC(263) Pause Cleanup [73.169s][info ][gc ] GC(263) Pause Cleanup 223M->213M(256M) 0.271ms [73.169s][info ][gc,cpu ] GC(263) User=0.00s Sys=0.00s Real=0.00s [73.169s][info ][gc,marking ] GC(263) Concurrent Complete Cleanup [73.169s][info ][gc,marking ] GC(263) Concurrent Complete Cleanup 0.013ms [73.169s][info ][gc,marking ] GC(263) Concurrent Cleanup for Next Mark [73.171s][info ][gc,marking ] GC(263) Concurrent Cleanup for Next Mark 1.646ms [73.171s][info ][gc ] GC(263) Concurrent Cycle 89.437ms TENURED COLLECTION jClarity
  • 42. Copyright 2018 Kirk Pepperdine COLLECTING TENURED ▸ Triggered at IHOP=45% ▸ Tenured regions are marked ▸region liveliness is calculated by the mark 23.615: [GC pause (Metadata GC Threshold) (young) (initial-mark) 23.649: [GC concurrent-root-region-scan-start] 23.698: [GC concurrent-root-region-scan-end, 0.0484826 secs] 23.698: [GC concurrent-mark-start] 23.889: [GC concurrent-mark-end, 0.1907474 secs] 23.889: [GC remark 23.889: [Finalize Marking, 0.0002867 secs] 23.889: [GC ref-proc, 0.0001423 secs] 23.889: [Unloading, 0.0094320 secs], 0.0123489 secs] 23.902: [GC cleanup 504M->500M(1024M), 0.0015885 secs] 23.903: [GC concurrent-cleanup-start] 23.903: [GC concurrent-cleanup-end, 0.0000172 secs] jClarity
  • 43. Copyright 2018 Kirk Pepperdine BUILDING A CSET REVISITED ▸ CSet contains all eden and survivor regions ▸a mixed collection will add a subset of tenured regions to the CSet ▸ CSet size is controlled by ▸the pause time goal (200ms default) ▸minimum collection percentages (10%) ▸other factors jClarity
  • 44. Copyright 2018 Kirk Pepperdine MARK AND CALCULATE LIVELINESS Tenured regions jClarity
  • 45. Copyright 2018 Kirk Pepperdine SORT BY LIVELINESS jClarity
  • 46. Copyright 2018 Kirk Pepperdine SORT BY LIVELINESS jClarity free eligible for collection not eligible -XX:G1MixedGCLiveThresholdPercent=85
  • 47. Copyright 2018 Kirk Pepperdine ELIGIBLE REGIONS jClarity
  • 48. Copyright 2018 Kirk Pepperdine MIXED COLLECTION COUNT jClarity -XX:G1OldCSetRegionThresholdPercent=10 -XX:G1HeapWastePercent=10 mixed 1 mixed 2 mixed 3 mixed 8…
  • 49. Copyright 2018 Kirk Pepperdine HUMONGOUS ALLOCATIONS Tenured Young jClarity Tenured Region Humungous Region (start) Humungous Region (cont) Survivor Region aka: to space Eden Region Unallocated Region
  • 50. Copyright 2018 Kirk Pepperdine HUMONGOUS ALLOCATIONS Humungous Region (start) Humungous Region (cont) jClarity ▸Allocation that is 1/2 the size of a region ▸Fragmented heaps may not have enough space to satisfy an allocation ▸ dip into reserved space ▸ trigger a young gen collection with and initial-mark ▸commit more regions to the heap ▸ worst case can trigger a Full GC
  • 51. Copyright 2018 Kirk Pepperdine RESERVED SPACE Tenured Region Humungous Region (start) Humungous Region (cont) Survivor Region aka: to space Eden Region Unallocated Region Tenured Young jClarity Reserved
  • 52. Copyright 2018 Kirk Pepperdine SOMETHINGS GONE OFF jClarity
  • 53. Copyright 2018 Kirk Pepperdine HOW TO GET A GC LOG jClarity -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintReferenceGC -Xlog:gc*,gc+ref,gc+phases=debug,gc+age=debug,safepoint:file=gc.log
  • 54. Copyright 2018 Kirk Pepperdine jClarity DON’T LIKE READING GC LOGS? I’ve got your back
  • 55. Copyright 2018 Kirk Pepperdine ▸ JDK 9 ▸ G1GC is default collector ▸ improve ability to determine important memory setting ▸ migrate GC logging to Unified logging ▸ JDK 10 ▸ Parallel full GC ▸ JDK 11 ▸ new perf counters for STW during concurrent collection ▸ adaptive parallel reference processing ▸ Adaptive scaling for threads RELEASE NOTES jClarity
  • 56. Copyright 2018 Kirk Pepperdine WHY IS IT TAKING SO LONG??? jClarity Lets look at a GC Log using Censum
  • 57. Copyright 2018 Kirk Pepperdine CONTROLLING OBJECT COPY COSTS volume of reachable objects jClarity Occupancy Age
  • 58. Copyright 2018 Kirk Pepperdine TEXT TITLE TEXT ▸ Body Level One ▸ Body Level Two ▸ Body Level Three ▸ Body Level Four ▸ Body Level Five Java Performance Tuning Workshop Send us a Java 11 GC log or tweet about @jclarity and #censum and receive a free Censum License