Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and Ergonomics.

Monica Beckwith
Monica BeckwithJava Champion. Java/JVM Performance - JavaOne Rock Star at Microsoft
Garbage-First Collector:
Current and Future
Adaptability and
Ergonomics.
Monica Beckwith Charlie Hunt John Cuthbertson
What's the talk about?
2
 Sneak a peek under the hood of the latest and
coolest garbage collector, Garbage-First!
 Dive deep into G1's adaptability and ergonomics
 Discuss the future of G1's adaptability
About the Presenters
3
 Charlie Hunt
Architect,
Performance
Engineering,
Salesforce
 Monica
Beckwith
Performance
Architect,
Servergy
 John
Cuthbertson
GC Guru,
Azul Systems
Agenda
 Key Concepts
 Definition
 Ergonomics
 Adaptability (if any)
 Future Adaptability Needs of G1
 Need More Information?
 Questions? - Let‟s Discuss!
4
Key Concepts
 Remembered Sets (RSets)
 Marking Threshold and Concurrent Cycle
 Collection Set (CSet) and Collections
 Mixed Collection
 Young Collection
 Old Regions Collection
 Humongous Allocations
 Evacuation Failures
 Reference Processing
5
Key Concept – Remembered Sets
6
Remembered Sets
 Per-region entries
 Each RSet keeps track of outside references
into its “owning” region
 RSets help regions to be independently GC‟d
 No need to scan the entire heap!
 G1 maintains RSets for –
 old-to-young and
 old-to-old references
7
Remembered Sets (RSets)
8
Region 2
Region 1
Region 3
RSet for
Region 1
RSet for
Region 3
RSet for
Region 2
* Figure referenced from InfoQ article: http://www.infoq.com/articles/tuning-tips-G1-GC
RSets – Ergonomics and Adaptability
 Concurrent Refinement threads –
 Help maintain RSets
 Concurrent updating
 Post-write Barriers –
 After a write
 Help track cross region updates
 Coarsening –
 RSets transitioning through different levels of
granularity
9
RSet - Concurrent Refinement
 Concurrent processing of the filled update
buffers
 Tiered deployment
 Max number can be set by
-XX:G1ConcRefinementThreads
 The processing of update buffers can eventually
fall to the mutator (application) threads
 Need to avoid such a scenario
10
RSet - Coarsenings
 Three levels of granularity –
 Sparse
 Hash table of card indices; Fastest to scan
 Fine
 Card indices held in a bitmap; Scan not as fast as Sparse
table
 Coarse
 One bit for each region; Slowest to scan
11
Key Concept – Marking Threshold
and Concurrent Cycle
12
Marking Threshold and Concurrent
Cycle
 Threshold default: 45% of your Java heap
 -XX:InitiatingHeapOccupancyPercent=<value>
 When threshold‟s crossed, G1 starts a
concurrent cycle
 Some phases are concurrent and some are stop-the
world
 Multi-phased concurrent marking cycle finds the
“best” regions to be collected
 Live-ness accounting
13
Marking Threshold and Concurrent
Cycle
 After the marking phase is complete, G1 has
information on which old regions to collect
 Regions are ordered based on “collection
efficiency”
 Expensive regions would be regions with lots of live
data and large RSets
 Completely free regions are collected during
cleanup phase
 Examples are shown later in this presentation …
14
Marking Threshold – Example 1
15
Default IHOP IHOP increased to 75%
Java heap size Java heap sizeMax heap occupancy
Max heap occupancy
Marking Threshold
Marking Threshold
Marking Threshold – Example 2
16
Default IHOP IHOP increased to
70%
25% Young GCs
60% Mixed GCs
30% Mixed GCs
64% Young GCs
Better to do more young GCs
than mixed GCs
Key Concept – Collection Set and
Collections
17
Collection Set
 A set of regions to be collected during a GC
evacuation pause
 Young Collection will have only and all young
regions in the CSet
 Mixed Collection will have both young and old
regions in the CSet
 Live data in the CSet is evacuated/copied
during a GC cycle
18
Collection Set – Young Collection
Look for the following in PrintAdaptiveSizePolicy enabled log –
6676.431: [GC pause (G1 Evacuation Pause) (young) 6676.431: [G1Ergonomics (CSet
Construction) start choosing CSet, _pending_cards: 147002, predicted base time: 42.39 ms,
remaining time: 157.61 ms, target pause time: 200.00 ms]
6676.431: [G1Ergonomics (CSet Construction) add young
regions to CSet, eden: 950 regions, survivors: 74 regions,
predicted young region time: 160.72 ms]
6676.431: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 950 regions,
survivors: 74 regions, old: 0 regions, predicted pause time: 203.11 ms, target pause time:
200.00 ms]
19
Collection Set – Mixed Collection
5884.952: [GC pause (G1 Evacuation Pause) (mixed) 5884.952: [G1Ergonomics (CSet
Construction) start choosing CSet, _pending_cards: 167183, predicted base time: 48.30 ms,
remaining time: 151.70 ms, target pause time: 200.00 ms]
5884.952: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 952 regions,
survivors: 72 regions, predicted young region time: 225.39 ms]
5884.954: [G1Ergonomics (CSet Construction) finish
adding old regions to CSet, reason: reclaimable percentage
not over threshold, old: 134 regions, max: 308 regions,
reclaimable: 1285706456 bytes (9.98 %), threshold: 10.00 %]
5884.954: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 952 regions,
survivors: 72 regions, old: 134 regions, predicted pause time: 354.55 ms, target pause time:
200.00 ms]
20
Collection Set – Mixed Collection
21
Young Regions
Old Regions
H Humongous Regions
✓ ✓
✓ ✓
✓ H ✓
✓
✓ H
✓
H ✓
* Figure shows both young and old collection sets.
Mixed Collection - Copying
22
✓ ✓
✓ ✓
✓ H ✓
✓
✓ H
✓
H ✓
Live objects are copied
into the “to-space”
regions:
- Survivor Regions
- Old Regions
Mixed Collection – Reclamation
23
✓ ✓
✓ ✓
✓ H ✓
✓
✓ H
✓
H ✓
G1 achieves
compaction via copying
CSet – Ergonomics and Adaptability
 CSet for young entirely depends on –
 The pause time target
 -XX:MaxGCPauseMillis=<value>
 All young regions are included in the CSet
 CSet for mixed collection –
 Could have a minimum number of regions based on
the MixedGCCountTarget and
 But will never cross the max number of regions set by
OldCSetThresholdPercent
24
CSet – Ergonomics and Adaptability
 -XX:G1MixedGCCountTarget (defaults to 8) – sets a target for
mixed collections by setting a minimum limit on the old regions
to collect per mixed collection, the goal is to not exceed the
CountTarget during the mixed collection cycle
 -XX:G1OldCSetRegionThresholdPercent (defaults to 10) – sets
an upper limit on the max number of old regions that can be
collected during a mixed collection (its expressed as a
percentage of the total heap)
25
CSet – Ergonomics and Adaptability
Snippets from a PrintAdaptiveSizePolicy enabled
log –
 <finish adding old regions to CSet, reason: predicted time is too high,
predicted time: 2.27 ms, remaining time: 0.00 ms, old: 12 regions,
min: 12 regions>
 <finish adding old regions to CSet, reason: old CSet region num
reached min, old: 142 regions, min: 142 regions>
 <finish adding old regions to CSet, reason: reclaimable percentage
not over threshold, old: 134 regions, max: 308 regions>
26
Mixed Collection – Ergonomics and
Adaptability
 Young regions – all young regions are
included in a collection
 Old regions are selected based on –
 -XX:G1MixedGCLiveThresholdPercent (defaults to 65) – sets a limit
on the live objects' occupancy such that any old region above that
threshold will not be included in any mixed collection
 Remember GC efficiency?
 -XX:G1HeapWastePercent (defaults to 10) – sets the waste target i.e.
the percentage of heap space you are willing to never collect in an
effort to avoid expensive GCs
 Remember the logs outputs that mentioned “reclaimable percentage not
over threshold”?
27
Young Collection – Ergonomics and
Adaptability
 Young generation size is based on your pause time
target and internally set min and max bounds
 -XX:MaxGCPauseMillis = 200 (default)
 Default min nursery size = 5% of your Java heap
 Default max nursery size = 60% of your Java heap
 Prediction logic
 Determines how much time it will take to collect 1 region
 (Re-)Sizes the young generation accordingly after each
collection
28
Old Regions Collection - Ergonomics
 During Mixed GCs
 Based on the criteria mentioned earlier
809.925: [G1Ergonomics (Mixed GCs) start
mixed GCs, reason: candidate old regions
available, candidate old regions: 4273 regions,
reclaimable: 111102028112 bytes (53.89 %),
threshold: 10.00 %]
29
Old Regions Collection - Ergonomics
 During concurrent cycle
 Entirely free (i.e. full of garbage) regions are collected
6530.615: [GC cleanup 13G->12G(18G), 0.0388540 secs]
 During Full GCs
 Collects and compacts all regions
154.725: [Full GC 1018M->369M(1024M), 1.6437640 secs]
[Eden: 0.0B(51.0M)->0.0B(51.0M) Survivors: 0.0B->0.0B Heap:
1018.3M(1024.0M)->369.4M(1024.0M)]
30
Key Concept – Humongous
Allocations
31
Humongous Objects –What Are
They?
 Objects that span >= 50% of G1‟s region size
 Ideally –
 Not that many in number
 Are long lived
 Allocated directly into the old generation into
Humongous Regions
 Avoids unnecessary copying back and forth and
expensive promotions
 Larger objects will need contiguous regions
32
Humongous Objects – WWG1D?
33
G1 Region –
Young Generation
G1 Region –
Old Generation
Object 1 < 50% of
G1 Region
Object 2 == 50%
of G1 Region
Object 3 > 50%
of G1 Region
Object 4 >
G1 Region
?
Humongous Objects – WWG1D?
34
G1 Region –
Young Generation
G1 Region –
Old Generation
Object 1 < 50% of
G1 Region
Object 2 == 50%
of G1 Region
Object 3 > 50%
of G1 Region
Object 4 >
G1 Region
* Object 4 will need contiguous regions
Object 4 - Humongous
Humongous Objects
35
Object 1 – NOT Humongous
Object 2 - Humongous
Object 3 - Humongous
* Object 4 needs contiguous regions
Wasted
Space
Humongous Objects – What’s The
Catch?
 As of 7u40, initial heap size (-Xms) determines
the region size
 G1 strives for 2048 regions
 Region size a factor of 2 ranging from 1M to 32M
 If there is a vast difference between the initial
and the max heap, normal objects may seem
humongous to G1!
36
Humongous Objects – What’s The
Catch?
 Let‟s look at this PrintAdaptiveSizePolicy enabled
log snippet (Note: G1 region size was 4MB):
 1361.680: [G1Ergonomics (Concurrent Cycles)
request concurrent cycle initiation, reason:
occupancy higher than threshold, occupancy:
1459617792 bytes, allocation request: 4194320
bytes, threshold: 1449551430 bytes (45.00 %),
source: concurrent humongous allocation]
37
Humongous Objects – What’s The
Catch?
 Notes from earlier snippet –
 Concurrent cycle requested
 Reason: Occupancy was higher than threshold
 Allocation size was 4194320 bytes
 Greater than 4MB, hence humongous allocation
 Notes from the log (not shown here) –
 Too many humongous allocations
 Concurrent cycles can‟t keep up with the allocations
 Resulting in to-space exhausted messages and eventually Full GCs
38
Humongous Objects – How to “Fix”
it?
 Let‟s find a region size that can accommodate
the humongous objects as regular allocations
 So the next region size up would be 8MB
 But, 4.000015MB > 50% of 8MB
 So, go to the next size up. i.e. 16MB
 Solution – Set your region size to 16MB
 -XX:G1HeapRegionSize=16M
39
Humongous Allocation –
Ergonomics
 Humongous Regions are not included in a
mixed collection
 Dead Humongous objects are collected during
cleanup and during Full GC
6569.877: [GC cleanup 6708M- >6384M(12G),
0.0181200 secs]
 Live Humongous objects are compacted through
during full GC
40
Key Concept – Evacuation Failures
41
Evacuation Failures
 Evacuation failures indicate that G1 ran out of
heap regions either –
 while copying to survivor regions or
 while promoting or copying live objects in-to the
old generation
 Prior to Java 7u40 evacuation failures shown as
a “to-space overflow” in the GC logs
 Java 7u40 onwards shows “to-space exhausted”
in the GC logs
42
Evacuation Failures – How to Avoid
Them?
 Get a baseline with bare minimum options:
 -Xmx, -Xms and -XX:MaxGCPauseMillis=<value>
 Over-tuning is NOT for G1
 Look at the output of PrintAdaptiveSizePolicy
 Too many humongous allocations?
 Increase G1HeapRegionSize
43
Evacuation Failures
 Plot the heap utilization stats from the log
 Marking threshold too high?
 Can‟t keep up with promotions
 Marking threshold too low?
 Not reclaiming much space from marking cycle
 Concurrent cycles taking a long time to
complete?
 Increase the thread count: ConcGCThreads
44
Evacuation Failures
 Sometimes survivor space gets exhausted
 Increase the G1ReservePercent
 It‟s a false ceiling
 Defaults to 10
 G1 will cap it off at 50%
45
Key Concept – Reference Processing
46
Reference Processing
47
0
10
20
30
40
50
60
70
80
90
100
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
User Time (in secs) System Time (in secs)
Real Time (in secs) Scaling
Reference Processing
48
9185.651: [GC remark 9185.653: [GC ref-proc, 5.2216490 secs], 5.2946850 secs]
[Times: user=5.62 sys=0.00, real=5.29 secs]
[Other: 339.7 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 287.8 ms]
[Ref Enq: 5.4 ms]
[Free CSet: 6.9 ms]
This is not good!
Parallel Reference Processing
49
0
10
20
30
40
50
60
70
80
90
100
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
[GCpause
remark
[GCpause
User Time (in secs) System Time (in secs)
Real Time (in secs) Scaling
After enabling -XX:+ParallelRefProcEnabled
Parallel Reference Processing
50
9095.305: [GC remark 9095.309: [GC ref-proc, 0.4888450
secs], 0.5621620 secs]
[Times: user=7.84 sys=0.03, real=0.56 secs]
[Other: 91.0 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 43.9 ms]
[Ref Enq: 1.0 ms]
[Free CSet: 7.4 ms]
Ooh yeah,
much better!
Future Adaptability
51
Future Adaptability
 Adaptive marking threshold?
 A static value doesn‟t cut it
 CMS has adaptive marking threshold with static
override and static max value
 Wouldn‟t it be nice if G1 had an adaptive threshold
and adaptive max value?
 Adaptive region size?
 Will help alleviate the issues that applications with
numerous short-lived “humongous” objects encounter
52
Future Adaptability
 Avoiding evacuation failures
 http://bugs.sun.com/bugdatabase/view_bug.do?bug
_id=8014019
 Reducing the cost of evacuation failures
 http://bugs.sun.com/bugdatabase/view_bug.do?bug
_id=8003237
 http://bugs.sun.com/bugdatabase/view_bug.do?bug
_id=8003235
53
Future Adaptability
 Improving RSets
 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7187490
 Improving concurrent refinement thresholds to
reduce the possibility of long RSet updating times.
 Smarter/ adaptable criteria for selecting CSet
for old regions
 Smarter/ adaptable Mixed Collections
 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7173711
54
Want More Info?
55
G1 Articles on the Web
 http://www.infoq.com/articles/G1-One-Garbage-Collector-To-
Rule-Them-All
 http://www.infoq.com/articles/tuning-tips-G1-GC
 http://www.oracle.com/technetwork/articles/java/g1gc-
1984535.html
 http://www.infoq.com/presentations/java-g1
 https://oracleus.activeevents.com/connect/sessionDetail.ww?SE
SSION_ID=6583
 https://blogs.oracle.com/javatraining/entry/getting_started_with
_the_g1
56
Questions?
Let‟s discuss „em!
57
More Questions?
HOL5429: Tuning Low-Pause Garbage Collection – Tue 10 am
CON3754: G1 GC: Migration to, Expectations, and Advanced Tuning –
Wed 10 am
CON7624: Understanding Java Garbage Collection and What You Can
Do About It. – Wed 11:30 am
GC Tuning BOF4020 - Tonight @7:30 pm
JVM Performance BOF4471 – Tonight @8:30 pm
Email: hotspot-gc-use@openjdk.java.net & hotspot-gc-
dev@openjdk.java.net
58
1 of 58

Recommended

Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva... by
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Monica Beckwith
48.6K views91 slides
Garbage First Garbage Collector: Where the Rubber Meets the Road! by
Garbage First Garbage Collector: Where the Rubber Meets the Road!Garbage First Garbage Collector: Where the Rubber Meets the Road!
Garbage First Garbage Collector: Where the Rubber Meets the Road!Monica Beckwith
2K views96 slides
Java 9: The (G1) GC Awakens! by
Java 9: The (G1) GC Awakens!Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Monica Beckwith
39.7K views99 slides
Let's Learn to Talk to GC Logs in Java 9 by
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 9Poonam Bajaj Parhar
4.8K views43 slides
Blazing Performance with Flame Graphs by
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBrendan Gregg
323.6K views170 slides
RedisConf18 - Redis Memory Optimization by
RedisConf18 - Redis Memory OptimizationRedisConf18 - Redis Memory Optimization
RedisConf18 - Redis Memory OptimizationRedis Labs
3.3K views51 slides

More Related Content

What's hot

Linux Performance Analysis: New Tools and Old Secrets by
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsBrendan Gregg
603.9K views75 slides
CPUから見たG1GC by
CPUから見たG1GCCPUから見たG1GC
CPUから見たG1GCKenji Kazumura
3.9K views49 slides
Ceph and RocksDB by
Ceph and RocksDBCeph and RocksDB
Ceph and RocksDBSage Weil
13.6K views19 slides
Jvm & Garbage collection tuning for low latencies application by
Jvm & Garbage collection tuning for low latencies applicationJvm & Garbage collection tuning for low latencies application
Jvm & Garbage collection tuning for low latencies applicationQuentin Ambard
1.8K views67 slides
JVMのGCアルゴリズムとチューニング by
JVMのGCアルゴリズムとチューニングJVMのGCアルゴリズムとチューニング
JVMのGCアルゴリズムとチューニング佑哉 廣岡
21.7K views96 slides
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas... by
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...DataStax
8.3K views33 slides

What's hot(20)

Linux Performance Analysis: New Tools and Old Secrets by Brendan Gregg
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
Brendan Gregg603.9K views
Ceph and RocksDB by Sage Weil
Ceph and RocksDBCeph and RocksDB
Ceph and RocksDB
Sage Weil13.6K views
Jvm & Garbage collection tuning for low latencies application by Quentin Ambard
Jvm & Garbage collection tuning for low latencies applicationJvm & Garbage collection tuning for low latencies application
Jvm & Garbage collection tuning for low latencies application
Quentin Ambard1.8K views
JVMのGCアルゴリズムとチューニング by 佑哉 廣岡
JVMのGCアルゴリズムとチューニングJVMのGCアルゴリズムとチューニング
JVMのGCアルゴリズムとチューニング
佑哉 廣岡21.7K views
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas... by DataStax
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
DataStax8.3K views
How Prometheus Store the Data by Hao Chen
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the Data
Hao Chen2.6K views
Jvm tuning for low latency application & Cassandra by Quentin Ambard
Jvm tuning for low latency application & CassandraJvm tuning for low latency application & Cassandra
Jvm tuning for low latency application & Cassandra
Quentin Ambard3.8K views
Deletes Without Tombstones or TTLs (Eric Stevens, ProtectWise) | Cassandra Su... by DataStax
Deletes Without Tombstones or TTLs (Eric Stevens, ProtectWise) | Cassandra Su...Deletes Without Tombstones or TTLs (Eric Stevens, ProtectWise) | Cassandra Su...
Deletes Without Tombstones or TTLs (Eric Stevens, ProtectWise) | Cassandra Su...
DataStax13.6K views
Ceph Block Devices: A Deep Dive by Red_Hat_Storage
Ceph Block Devices:  A Deep DiveCeph Block Devices:  A Deep Dive
Ceph Block Devices: A Deep Dive
Red_Hat_Storage7.3K views
Go Programming Patterns by Hao Chen
Go Programming PatternsGo Programming Patterns
Go Programming Patterns
Hao Chen3.2K views
How Development Teams Cut Costs with ScyllaDB.pdf by ScyllaDB
How Development Teams Cut Costs with ScyllaDB.pdfHow Development Teams Cut Costs with ScyllaDB.pdf
How Development Teams Cut Costs with ScyllaDB.pdf
ScyllaDB292 views
使ってみよう!JDK Flight Recorder by Yoshiro Tokumasu
使ってみよう!JDK Flight Recorder使ってみよう!JDK Flight Recorder
使ってみよう!JDK Flight Recorder
Yoshiro Tokumasu2.3K views
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers by Cloudera, Inc.
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersHBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
Cloudera, Inc.15.6K views
Javaday 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneur... by Jean-Philippe BEMPEL
Javaday 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneur...Javaday 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneur...
Javaday 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneur...
Let's talk about Garbage Collection by Haim Yadid
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
Haim Yadid2.9K views
Deep dive into PostgreSQL statistics. by Alexey Lesovsky
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
Alexey Lesovsky3.7K views

Viewers also liked

GC Tuning Confessions Of A Performance Engineer - Improved :) by
GC Tuning Confessions Of A Performance Engineer - Improved :)GC Tuning Confessions Of A Performance Engineer - Improved :)
GC Tuning Confessions Of A Performance Engineer - Improved :)Monica Beckwith
2.7K views92 slides
JFokus Java 9 contended locking performance by
JFokus Java 9 contended locking performanceJFokus Java 9 contended locking performance
JFokus Java 9 contended locking performanceMonica Beckwith
1.3K views57 slides
Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6 by
Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6
Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6Yuji Kubota
74.8K views86 slides
Game of Performance: A Song of JIT and GC by
Game of Performance: A Song of JIT and GCGame of Performance: A Song of JIT and GC
Game of Performance: A Song of JIT and GCMonica Beckwith
1.5K views106 slides
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation by
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationMonica Beckwith
1.7K views120 slides
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th... by
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...Monica Beckwith
2.3K views99 slides

Viewers also liked(15)

GC Tuning Confessions Of A Performance Engineer - Improved :) by Monica Beckwith
GC Tuning Confessions Of A Performance Engineer - Improved :)GC Tuning Confessions Of A Performance Engineer - Improved :)
GC Tuning Confessions Of A Performance Engineer - Improved :)
Monica Beckwith2.7K views
JFokus Java 9 contended locking performance by Monica Beckwith
JFokus Java 9 contended locking performanceJFokus Java 9 contended locking performance
JFokus Java 9 contended locking performance
Monica Beckwith1.3K views
Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6 by Yuji Kubota
Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6
Garbage First Garbage Collection (G1 GC) #jjug_ccc #ccc_cd6
Yuji Kubota74.8K views
Game of Performance: A Song of JIT and GC by Monica Beckwith
Game of Performance: A Song of JIT and GCGame of Performance: A Song of JIT and GC
Game of Performance: A Song of JIT and GC
Monica Beckwith1.5K views
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation by Monica Beckwith
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
Monica Beckwith1.7K views
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th... by Monica Beckwith
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
Monica Beckwith2.3K views
Java Performance Engineer's Survival Guide by Monica Beckwith
Java Performance Engineer's Survival GuideJava Performance Engineer's Survival Guide
Java Performance Engineer's Survival Guide
Monica Beckwith3.7K views
OFFICE ERGONOMICS: WHAT, HOW & WHY. An Essential Reading For Office Workers. by Abdul Shukor
OFFICE ERGONOMICS: WHAT, HOW & WHY. An Essential Reading For Office Workers.OFFICE ERGONOMICS: WHAT, HOW & WHY. An Essential Reading For Office Workers.
OFFICE ERGONOMICS: WHAT, HOW & WHY. An Essential Reading For Office Workers.
Abdul Shukor7.7K views
GC Tuning Confessions Of A Performance Engineer by Monica Beckwith
GC Tuning Confessions Of A Performance EngineerGC Tuning Confessions Of A Performance Engineer
GC Tuning Confessions Of A Performance Engineer
Monica Beckwith12.2K views
楽して JVM を学びたい #jjug by Yuji Kubota
楽して JVM を学びたい #jjug楽して JVM を学びたい #jjug
楽して JVM を学びたい #jjug
Yuji Kubota23.8K views
JVM のいろはにほ #javajo by Yuji Kubota
JVM のいろはにほ #javajoJVM のいろはにほ #javajo
JVM のいろはにほ #javajo
Yuji Kubota27.3K views
Concurrent Mark-Sweep Garbage Collection #jjug_ccc by Yuji Kubota
Concurrent Mark-Sweep Garbage Collection #jjug_cccConcurrent Mark-Sweep Garbage Collection #jjug_ccc
Concurrent Mark-Sweep Garbage Collection #jjug_ccc
Yuji Kubota115.2K views
Ergonomics Presentation by kitten23
Ergonomics PresentationErgonomics Presentation
Ergonomics Presentation
kitten2312.5K views
Ergonomics Presentation Final by krisazavache
Ergonomics Presentation FinalErgonomics Presentation Final
Ergonomics Presentation Final
krisazavache55.7K views

Similar to Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and Ergonomics.

G1GC by
G1GCG1GC
G1GCkoji lin
1.7K views48 slides
JVM memory management & Diagnostics by
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & DiagnosticsDhaval Shah
358 views24 slides
G1 Garbage Collector - Big Heaps and Low Pauses? by
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
16.1K views56 slides
Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud... by
Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud...Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud...
Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud...Ana-Maria Mihalceanu
25 views89 slides
Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14 by
Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14
Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14Jayesh Thakrar
488 views17 slides
java memory management & gc by
java memory management & gcjava memory management & gc
java memory management & gcexsuns
10.1K views38 slides

Similar to Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and Ergonomics.(20)

G1GC by koji lin
G1GCG1GC
G1GC
koji lin1.7K views
JVM memory management & Diagnostics by Dhaval Shah
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & Diagnostics
Dhaval Shah358 views
G1 Garbage Collector - Big Heaps and Low Pauses? by C2B2 Consulting
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 Consulting16.1K views
Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud... by Ana-Maria Mihalceanu
Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud...Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud...
Calibrate Garbage Collection on the Ground and Run Your Java App in the cloud...
Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14 by Jayesh Thakrar
Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14
Chicago-Java-User-Group-Meetup-Some-Garbage-Talk-2015-01-14
Jayesh Thakrar488 views
java memory management & gc by exsuns
java memory management & gcjava memory management & gc
java memory management & gc
exsuns10.1K views
What you need to know about GC by Kelum Senanayake
What you need to know about GCWhat you need to know about GC
What you need to know about GC
Kelum Senanayake14.3K views
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector by Gurpreet Sachdeva
Java Garbage Collectors – Moving to Java7 Garbage First (G1) CollectorJava Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Gurpreet Sachdeva1.8K views
Am I reading GC logs Correctly? by Tier1 App
Am I reading GC logs Correctly?Am I reading GC logs Correctly?
Am I reading GC logs Correctly?
Tier1 App2K views
7-JVM-arguments-JaxLondon-2023.pptx by Tier1 app
7-JVM-arguments-JaxLondon-2023.pptx7-JVM-arguments-JaxLondon-2023.pptx
7-JVM-arguments-JaxLondon-2023.pptx
Tier1 app176 views
Accelerate Reed-Solomon coding for Fault-Tolerance in RAID-like system by Shuai Yuan
Accelerate Reed-Solomon coding for Fault-Tolerance in RAID-like systemAccelerate Reed-Solomon coding for Fault-Tolerance in RAID-like system
Accelerate Reed-Solomon coding for Fault-Tolerance in RAID-like system
Shuai Yuan294 views
Demystifying Garbage Collection in Java by Igor Braga
Demystifying Garbage Collection in JavaDemystifying Garbage Collection in Java
Demystifying Garbage Collection in Java
Igor Braga44 views
JVM Garbage Collection Tuning by ihji
JVM Garbage Collection TuningJVM Garbage Collection Tuning
JVM Garbage Collection Tuning
ihji2.7K views
Вячеслав Блинов «Java Garbage Collection: A Performance Impact» by Anna Shymchenko
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Anna Shymchenko569 views
An introduction to G1 collector for busy developers by Sanjoy Kumar Roy
An introduction to G1 collector for busy developersAn introduction to G1 collector for busy developers
An introduction to G1 collector for busy developers
Sanjoy Kumar Roy651 views
Garbage collection in JVM by aragozin
Garbage collection in JVMGarbage collection in JVM
Garbage collection in JVM
aragozin12.8K views
Garbage Collection of Java VM by Yongqiang Li
Garbage Collection of Java VMGarbage Collection of Java VM
Garbage Collection of Java VM
Yongqiang Li1.6K views

More from Monica Beckwith

QCon London.pdf by
QCon London.pdfQCon London.pdf
QCon London.pdfMonica Beckwith
136 views33 slides
Enabling Java: Windows on Arm64 - A Success Story! by
Enabling Java: Windows on Arm64 - A Success Story!Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!Monica Beckwith
192 views32 slides
Applying Concurrency Cookbook Recipes to SPEC JBB by
Applying Concurrency Cookbook Recipes to SPEC JBBApplying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBBMonica Beckwith
302 views43 slides
Intro to Garbage Collection by
Intro to Garbage CollectionIntro to Garbage Collection
Intro to Garbage CollectionMonica Beckwith
198 views33 slides
OpenJDK Concurrent Collectors by
OpenJDK Concurrent CollectorsOpenJDK Concurrent Collectors
OpenJDK Concurrent CollectorsMonica Beckwith
394 views51 slides
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS by
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORSOPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORSMonica Beckwith
277 views50 slides

More from Monica Beckwith(8)

Enabling Java: Windows on Arm64 - A Success Story! by Monica Beckwith
Enabling Java: Windows on Arm64 - A Success Story!Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!
Monica Beckwith192 views
Applying Concurrency Cookbook Recipes to SPEC JBB by Monica Beckwith
Applying Concurrency Cookbook Recipes to SPEC JBBApplying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBB
Monica Beckwith302 views
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS by Monica Beckwith
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORSOPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
Monica Beckwith277 views
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine by Monica Beckwith
The Performance Engineer's Guide to Java (HotSpot) Virtual MachineThe Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
Monica Beckwith1.9K views
Way Improved :) GC Tuning Confessions - presented at JavaOne2015 by Monica Beckwith
Way Improved :) GC Tuning Confessions - presented at JavaOne2015Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Monica Beckwith4.1K views

Recently uploaded

Lilypad @ Labweek, Istanbul, 2023.pdf by
Lilypad @ Labweek, Istanbul, 2023.pdfLilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdfAlly339821
9 views45 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
33 views69 slides
The details of description: Techniques, tips, and tangents on alternative tex... by
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
126 views24 slides
STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
13 views1 slide
ChatGPT and AI for Web Developers by
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web DevelopersMaximiliano Firtman
187 views82 slides
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...James Anderson
66 views32 slides

Recently uploaded(20)

Lilypad @ Labweek, Istanbul, 2023.pdf by Ally339821
Lilypad @ Labweek, Istanbul, 2023.pdfLilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdf
Ally3398219 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker33 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada126 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb13 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson66 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst476 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software257 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 views
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291616 views
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn21 views
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg16 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi126 views

Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and Ergonomics.

  • 1. Garbage-First Collector: Current and Future Adaptability and Ergonomics. Monica Beckwith Charlie Hunt John Cuthbertson
  • 2. What's the talk about? 2  Sneak a peek under the hood of the latest and coolest garbage collector, Garbage-First!  Dive deep into G1's adaptability and ergonomics  Discuss the future of G1's adaptability
  • 3. About the Presenters 3  Charlie Hunt Architect, Performance Engineering, Salesforce  Monica Beckwith Performance Architect, Servergy  John Cuthbertson GC Guru, Azul Systems
  • 4. Agenda  Key Concepts  Definition  Ergonomics  Adaptability (if any)  Future Adaptability Needs of G1  Need More Information?  Questions? - Let‟s Discuss! 4
  • 5. Key Concepts  Remembered Sets (RSets)  Marking Threshold and Concurrent Cycle  Collection Set (CSet) and Collections  Mixed Collection  Young Collection  Old Regions Collection  Humongous Allocations  Evacuation Failures  Reference Processing 5
  • 6. Key Concept – Remembered Sets 6
  • 7. Remembered Sets  Per-region entries  Each RSet keeps track of outside references into its “owning” region  RSets help regions to be independently GC‟d  No need to scan the entire heap!  G1 maintains RSets for –  old-to-young and  old-to-old references 7
  • 8. Remembered Sets (RSets) 8 Region 2 Region 1 Region 3 RSet for Region 1 RSet for Region 3 RSet for Region 2 * Figure referenced from InfoQ article: http://www.infoq.com/articles/tuning-tips-G1-GC
  • 9. RSets – Ergonomics and Adaptability  Concurrent Refinement threads –  Help maintain RSets  Concurrent updating  Post-write Barriers –  After a write  Help track cross region updates  Coarsening –  RSets transitioning through different levels of granularity 9
  • 10. RSet - Concurrent Refinement  Concurrent processing of the filled update buffers  Tiered deployment  Max number can be set by -XX:G1ConcRefinementThreads  The processing of update buffers can eventually fall to the mutator (application) threads  Need to avoid such a scenario 10
  • 11. RSet - Coarsenings  Three levels of granularity –  Sparse  Hash table of card indices; Fastest to scan  Fine  Card indices held in a bitmap; Scan not as fast as Sparse table  Coarse  One bit for each region; Slowest to scan 11
  • 12. Key Concept – Marking Threshold and Concurrent Cycle 12
  • 13. Marking Threshold and Concurrent Cycle  Threshold default: 45% of your Java heap  -XX:InitiatingHeapOccupancyPercent=<value>  When threshold‟s crossed, G1 starts a concurrent cycle  Some phases are concurrent and some are stop-the world  Multi-phased concurrent marking cycle finds the “best” regions to be collected  Live-ness accounting 13
  • 14. Marking Threshold and Concurrent Cycle  After the marking phase is complete, G1 has information on which old regions to collect  Regions are ordered based on “collection efficiency”  Expensive regions would be regions with lots of live data and large RSets  Completely free regions are collected during cleanup phase  Examples are shown later in this presentation … 14
  • 15. Marking Threshold – Example 1 15 Default IHOP IHOP increased to 75% Java heap size Java heap sizeMax heap occupancy Max heap occupancy Marking Threshold Marking Threshold
  • 16. Marking Threshold – Example 2 16 Default IHOP IHOP increased to 70% 25% Young GCs 60% Mixed GCs 30% Mixed GCs 64% Young GCs Better to do more young GCs than mixed GCs
  • 17. Key Concept – Collection Set and Collections 17
  • 18. Collection Set  A set of regions to be collected during a GC evacuation pause  Young Collection will have only and all young regions in the CSet  Mixed Collection will have both young and old regions in the CSet  Live data in the CSet is evacuated/copied during a GC cycle 18
  • 19. Collection Set – Young Collection Look for the following in PrintAdaptiveSizePolicy enabled log – 6676.431: [GC pause (G1 Evacuation Pause) (young) 6676.431: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 147002, predicted base time: 42.39 ms, remaining time: 157.61 ms, target pause time: 200.00 ms] 6676.431: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 950 regions, survivors: 74 regions, predicted young region time: 160.72 ms] 6676.431: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 950 regions, survivors: 74 regions, old: 0 regions, predicted pause time: 203.11 ms, target pause time: 200.00 ms] 19
  • 20. Collection Set – Mixed Collection 5884.952: [GC pause (G1 Evacuation Pause) (mixed) 5884.952: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 167183, predicted base time: 48.30 ms, remaining time: 151.70 ms, target pause time: 200.00 ms] 5884.952: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 952 regions, survivors: 72 regions, predicted young region time: 225.39 ms] 5884.954: [G1Ergonomics (CSet Construction) finish adding old regions to CSet, reason: reclaimable percentage not over threshold, old: 134 regions, max: 308 regions, reclaimable: 1285706456 bytes (9.98 %), threshold: 10.00 %] 5884.954: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 952 regions, survivors: 72 regions, old: 134 regions, predicted pause time: 354.55 ms, target pause time: 200.00 ms] 20
  • 21. Collection Set – Mixed Collection 21 Young Regions Old Regions H Humongous Regions ✓ ✓ ✓ ✓ ✓ H ✓ ✓ ✓ H ✓ H ✓ * Figure shows both young and old collection sets.
  • 22. Mixed Collection - Copying 22 ✓ ✓ ✓ ✓ ✓ H ✓ ✓ ✓ H ✓ H ✓ Live objects are copied into the “to-space” regions: - Survivor Regions - Old Regions
  • 23. Mixed Collection – Reclamation 23 ✓ ✓ ✓ ✓ ✓ H ✓ ✓ ✓ H ✓ H ✓ G1 achieves compaction via copying
  • 24. CSet – Ergonomics and Adaptability  CSet for young entirely depends on –  The pause time target  -XX:MaxGCPauseMillis=<value>  All young regions are included in the CSet  CSet for mixed collection –  Could have a minimum number of regions based on the MixedGCCountTarget and  But will never cross the max number of regions set by OldCSetThresholdPercent 24
  • 25. CSet – Ergonomics and Adaptability  -XX:G1MixedGCCountTarget (defaults to 8) – sets a target for mixed collections by setting a minimum limit on the old regions to collect per mixed collection, the goal is to not exceed the CountTarget during the mixed collection cycle  -XX:G1OldCSetRegionThresholdPercent (defaults to 10) – sets an upper limit on the max number of old regions that can be collected during a mixed collection (its expressed as a percentage of the total heap) 25
  • 26. CSet – Ergonomics and Adaptability Snippets from a PrintAdaptiveSizePolicy enabled log –  <finish adding old regions to CSet, reason: predicted time is too high, predicted time: 2.27 ms, remaining time: 0.00 ms, old: 12 regions, min: 12 regions>  <finish adding old regions to CSet, reason: old CSet region num reached min, old: 142 regions, min: 142 regions>  <finish adding old regions to CSet, reason: reclaimable percentage not over threshold, old: 134 regions, max: 308 regions> 26
  • 27. Mixed Collection – Ergonomics and Adaptability  Young regions – all young regions are included in a collection  Old regions are selected based on –  -XX:G1MixedGCLiveThresholdPercent (defaults to 65) – sets a limit on the live objects' occupancy such that any old region above that threshold will not be included in any mixed collection  Remember GC efficiency?  -XX:G1HeapWastePercent (defaults to 10) – sets the waste target i.e. the percentage of heap space you are willing to never collect in an effort to avoid expensive GCs  Remember the logs outputs that mentioned “reclaimable percentage not over threshold”? 27
  • 28. Young Collection – Ergonomics and Adaptability  Young generation size is based on your pause time target and internally set min and max bounds  -XX:MaxGCPauseMillis = 200 (default)  Default min nursery size = 5% of your Java heap  Default max nursery size = 60% of your Java heap  Prediction logic  Determines how much time it will take to collect 1 region  (Re-)Sizes the young generation accordingly after each collection 28
  • 29. Old Regions Collection - Ergonomics  During Mixed GCs  Based on the criteria mentioned earlier 809.925: [G1Ergonomics (Mixed GCs) start mixed GCs, reason: candidate old regions available, candidate old regions: 4273 regions, reclaimable: 111102028112 bytes (53.89 %), threshold: 10.00 %] 29
  • 30. Old Regions Collection - Ergonomics  During concurrent cycle  Entirely free (i.e. full of garbage) regions are collected 6530.615: [GC cleanup 13G->12G(18G), 0.0388540 secs]  During Full GCs  Collects and compacts all regions 154.725: [Full GC 1018M->369M(1024M), 1.6437640 secs] [Eden: 0.0B(51.0M)->0.0B(51.0M) Survivors: 0.0B->0.0B Heap: 1018.3M(1024.0M)->369.4M(1024.0M)] 30
  • 31. Key Concept – Humongous Allocations 31
  • 32. Humongous Objects –What Are They?  Objects that span >= 50% of G1‟s region size  Ideally –  Not that many in number  Are long lived  Allocated directly into the old generation into Humongous Regions  Avoids unnecessary copying back and forth and expensive promotions  Larger objects will need contiguous regions 32
  • 33. Humongous Objects – WWG1D? 33 G1 Region – Young Generation G1 Region – Old Generation Object 1 < 50% of G1 Region Object 2 == 50% of G1 Region Object 3 > 50% of G1 Region Object 4 > G1 Region ?
  • 34. Humongous Objects – WWG1D? 34 G1 Region – Young Generation G1 Region – Old Generation Object 1 < 50% of G1 Region Object 2 == 50% of G1 Region Object 3 > 50% of G1 Region Object 4 > G1 Region * Object 4 will need contiguous regions
  • 35. Object 4 - Humongous Humongous Objects 35 Object 1 – NOT Humongous Object 2 - Humongous Object 3 - Humongous * Object 4 needs contiguous regions Wasted Space
  • 36. Humongous Objects – What’s The Catch?  As of 7u40, initial heap size (-Xms) determines the region size  G1 strives for 2048 regions  Region size a factor of 2 ranging from 1M to 32M  If there is a vast difference between the initial and the max heap, normal objects may seem humongous to G1! 36
  • 37. Humongous Objects – What’s The Catch?  Let‟s look at this PrintAdaptiveSizePolicy enabled log snippet (Note: G1 region size was 4MB):  1361.680: [G1Ergonomics (Concurrent Cycles) request concurrent cycle initiation, reason: occupancy higher than threshold, occupancy: 1459617792 bytes, allocation request: 4194320 bytes, threshold: 1449551430 bytes (45.00 %), source: concurrent humongous allocation] 37
  • 38. Humongous Objects – What’s The Catch?  Notes from earlier snippet –  Concurrent cycle requested  Reason: Occupancy was higher than threshold  Allocation size was 4194320 bytes  Greater than 4MB, hence humongous allocation  Notes from the log (not shown here) –  Too many humongous allocations  Concurrent cycles can‟t keep up with the allocations  Resulting in to-space exhausted messages and eventually Full GCs 38
  • 39. Humongous Objects – How to “Fix” it?  Let‟s find a region size that can accommodate the humongous objects as regular allocations  So the next region size up would be 8MB  But, 4.000015MB > 50% of 8MB  So, go to the next size up. i.e. 16MB  Solution – Set your region size to 16MB  -XX:G1HeapRegionSize=16M 39
  • 40. Humongous Allocation – Ergonomics  Humongous Regions are not included in a mixed collection  Dead Humongous objects are collected during cleanup and during Full GC 6569.877: [GC cleanup 6708M- >6384M(12G), 0.0181200 secs]  Live Humongous objects are compacted through during full GC 40
  • 41. Key Concept – Evacuation Failures 41
  • 42. Evacuation Failures  Evacuation failures indicate that G1 ran out of heap regions either –  while copying to survivor regions or  while promoting or copying live objects in-to the old generation  Prior to Java 7u40 evacuation failures shown as a “to-space overflow” in the GC logs  Java 7u40 onwards shows “to-space exhausted” in the GC logs 42
  • 43. Evacuation Failures – How to Avoid Them?  Get a baseline with bare minimum options:  -Xmx, -Xms and -XX:MaxGCPauseMillis=<value>  Over-tuning is NOT for G1  Look at the output of PrintAdaptiveSizePolicy  Too many humongous allocations?  Increase G1HeapRegionSize 43
  • 44. Evacuation Failures  Plot the heap utilization stats from the log  Marking threshold too high?  Can‟t keep up with promotions  Marking threshold too low?  Not reclaiming much space from marking cycle  Concurrent cycles taking a long time to complete?  Increase the thread count: ConcGCThreads 44
  • 45. Evacuation Failures  Sometimes survivor space gets exhausted  Increase the G1ReservePercent  It‟s a false ceiling  Defaults to 10  G1 will cap it off at 50% 45
  • 46. Key Concept – Reference Processing 46
  • 48. Reference Processing 48 9185.651: [GC remark 9185.653: [GC ref-proc, 5.2216490 secs], 5.2946850 secs] [Times: user=5.62 sys=0.00, real=5.29 secs] [Other: 339.7 ms] [Choose CSet: 0.0 ms] [Ref Proc: 287.8 ms] [Ref Enq: 5.4 ms] [Free CSet: 6.9 ms] This is not good!
  • 50. Parallel Reference Processing 50 9095.305: [GC remark 9095.309: [GC ref-proc, 0.4888450 secs], 0.5621620 secs] [Times: user=7.84 sys=0.03, real=0.56 secs] [Other: 91.0 ms] [Choose CSet: 0.0 ms] [Ref Proc: 43.9 ms] [Ref Enq: 1.0 ms] [Free CSet: 7.4 ms] Ooh yeah, much better!
  • 52. Future Adaptability  Adaptive marking threshold?  A static value doesn‟t cut it  CMS has adaptive marking threshold with static override and static max value  Wouldn‟t it be nice if G1 had an adaptive threshold and adaptive max value?  Adaptive region size?  Will help alleviate the issues that applications with numerous short-lived “humongous” objects encounter 52
  • 53. Future Adaptability  Avoiding evacuation failures  http://bugs.sun.com/bugdatabase/view_bug.do?bug _id=8014019  Reducing the cost of evacuation failures  http://bugs.sun.com/bugdatabase/view_bug.do?bug _id=8003237  http://bugs.sun.com/bugdatabase/view_bug.do?bug _id=8003235 53
  • 54. Future Adaptability  Improving RSets  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7187490  Improving concurrent refinement thresholds to reduce the possibility of long RSet updating times.  Smarter/ adaptable criteria for selecting CSet for old regions  Smarter/ adaptable Mixed Collections  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7173711 54
  • 56. G1 Articles on the Web  http://www.infoq.com/articles/G1-One-Garbage-Collector-To- Rule-Them-All  http://www.infoq.com/articles/tuning-tips-G1-GC  http://www.oracle.com/technetwork/articles/java/g1gc- 1984535.html  http://www.infoq.com/presentations/java-g1  https://oracleus.activeevents.com/connect/sessionDetail.ww?SE SSION_ID=6583  https://blogs.oracle.com/javatraining/entry/getting_started_with _the_g1 56
  • 58. More Questions? HOL5429: Tuning Low-Pause Garbage Collection – Tue 10 am CON3754: G1 GC: Migration to, Expectations, and Advanced Tuning – Wed 10 am CON7624: Understanding Java Garbage Collection and What You Can Do About It. – Wed 11:30 am GC Tuning BOF4020 - Tonight @7:30 pm JVM Performance BOF4471 – Tonight @8:30 pm Email: hotspot-gc-use@openjdk.java.net & hotspot-gc- dev@openjdk.java.net 58

Editor's Notes

  1. These are the same graphs we used for Qcon… we can replace the data with Charlie’s data.