SlideShare ist ein Scribd-Unternehmen logo
1 von 50
© 2018 Arm Limited1
OPENJDK: IN THE NEW AGE OF
CONCURRENT GARBAGE COLLECTORS
Monica Beckwith
© 2018 Arm Limited2
About Me
Java Champion, JavaOne Rock Star
Regular speaker at various tech conferences
Several published articles on topics including garbage collection, the Java memory model and
others.
Led Oracle’s Garbage First GC performance
Java VM Performance Architect, Arm
© 2018 Arm Limited3
Agenda
What I’ll try to cover in the next ~50 minutes
Part 1 – Groundwork & Commonalities
Laying the Groundwork -
Stop-the-world vs concurrent collection
Heap layout – regions and generations
Basic Commonalities –
Copying collector – from and to spaces
Regions - occupied and free
Collection set and priority
Part 2 – Introduction & Differences
Introduction to G1, Shenandoah and Z GCs –
Algorithm
Basic Differences –
GC phases
Marking algorithm
Barriers
Copying
© 2018 Arm Limited4
HotSpot Regionalized GCs:
Groundwork
© 2018 Arm Limited5
STW vs Concurrent
© 2018 Arm Limited6
Application Threads
STW
© 2018 Arm Limited7
Application Threads
Safepoint
Requested
STW
© 2018 Arm Limited8
Application Threads
Global
or
Thread
Local?
Safepoint
Requested
STW
© 2018 Arm Limited9
Application Threads
Safepoint
Executed
Time To Safepoint
(TTSP)
Safepoint
Requested
Global STW
© 2018 Arm Limited10
Application Threads
Safepoint
Executed
Time To Safepoint
(TTSP)
GC Threads Application Threads
Safepoint
Requested
GC
Completed
Global STW
© 2018 Arm Limited11
Application Threads
Global
or
Thread
Local?
Safepoint
Requested
Thread Local Handshakes
© 2018 Arm Limited12
Application Threads
Safepoint
Requested
Thread Local Handshakes
© 2018 Arm Limited13
Application Threads
GC Threads
Application Threads
Safepoint
Requested
GC
Completed
Thread Local Handshakes
Handshakes
© 2018 Arm Limited14
Application Threads
GC Threads
Application Threads
Safepoint
Requested
GC
Completed
Application Threads GC Threads Application Threads
Safepoint
Requested
GC
Completed
Handshakes
Thread Local Handshakes vs Global STW
© 2018 Arm Limited15
Concurrent GC
Application Threads
GC Threads
© 2018 Arm Limited16
Heap Layout
Heap
Z GC
Shenandoah GC
Young Generation
G1 GC
Old Generation
© 2018 Arm Limited17
HotSpot Regionalized GCs:
Basic Commonalities
© 2018 Arm Limited18
Copying Collector aka Compacting Collector aka Evacuation
HeapFrom Space To Space
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
GC ROOTS
THREAD 1
STACK
THREAD N
STACK
STATIC
VARIABLES
ANY JNI
REFERENCES
© 2018 Arm Limited19
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
GC ROOTS
THREAD 1
STACK
THREAD N
STACK
O O
O O
O
STATIC
VARIABLES
ANY JNI
REFERENCES
O
OO
O
O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
Copying Collector aka Compacting Collector aka Evacuation
© 2018 Arm Limited20
O O O O O O O O
O O O O O O O
O O O O O O O
O O O
O O O
O O
Copying Collector aka Compacting Collector aka Evacuation
© 2018 Arm Limited21
Occupied and Free Regions
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O
O O O O
O O O O
• List of free regions
• In case of generational heap (like G1), the occupied regions could be young, old or humongous
© 2018 Arm Limited22
Collection Priority and Collection Set
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O
O O O O
O O O O
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OO
OOOO
• Priority is to reclaim regions with most garbage
• The candidate regions for collection/reclamation/relocation are said to be in a collection set
• There are threshold based on how expensive a region can get and maximum regions to collect
• Incremental collection aka incremental compaction or partial compaction
• Usually needs a threshold that triggers the compaction
• Stops after the desired reclamation threshold or free-ness threshold is reached
• Doesn’t need to be stop-the-world
© 2018 Arm Limited23
HotSpot Regionalized GCs:
Introduction
© 2018 Arm Limited24
Algorithm & Other Considerations
Garbage Collectors G1 GC Shenandoah GC Z GC
Regionalized? Yes Yes Yes
Generational? Yes No No
Compaction? Yes, STW, Forwarding
address in header
Yes, Concurrent, Brooks
Style Indirection Pointer
Yes, Concurrent,
Colored Pointers
Target Pause Times? 200ms 10ms 10ms
Concurrent Marking Algorithm? SATB SATB Striped
© 2018 Arm Limited25
Algorithm & Other Considerations
Garbage Collectors G1 GC Shenandoah GC Z GC
Regionalized? Yes Yes Yes
Generational? Yes No No
Compaction? Yes, STW, Forwarding
address in header
Yes, Concurrent, Brooks
Style Indirection Pointer
Yes, Concurrent,
Colored Pointers
Target Pause Times? 200ms 10ms 10ms
Concurrent Marking Algorithm? SATB SATB Striped
© 2018 Arm Limited26
Algorithm & Other Considerations
Garbage Collectors G1 GC Shenandoah GC Z GC
Regionalized? Yes Yes Yes
Generational? Yes No No
Compaction? Yes, STW, Forwarding
address in header
Yes, Concurrent, Brooks
Style Indirection Pointer
Yes, Concurrent,
Colored Pointers
Target Pause Times? 200ms 10ms 10ms
Concurrent Marking Algorithm? SATB SATB Striped
© 2018 Arm Limited27
Algorithm & Other Considerations
Garbage Collectors G1 GC Shenandoah GC Z GC
Regionalized? Yes Yes Yes
Generational? Yes No No
Compaction? Yes, STW, Forwarding
address in header
Yes, Concurrent, Brooks
Style Indirection Pointer
Yes, Concurrent,
Colored Pointers
Target Pause Times? 200ms 10ms 10ms
Concurrent Marking Algorithm? SATB SATB Striped
© 2018 Arm Limited28
HotSpot Regionalized GCs:
Basic Differences – G1
© 2018 Arm Limited29
GC Phases of Marking & Compaction
G1 GC Gist
Initial Mark Mark objects directly reachable by the roots
Concurrent Root Region Scanning Since initial mark is piggy-backed on a young collection, the survivor regions
need to be scanned
Concurrent Marking Snapshot-at-the-beginning (SATB) algorithm
Final Marking Drain SATB buffers; traverse unvisited live objects
Cleanup Identify and free completely free regions, sort regions based on liveness and
expense
STW Compaction Move objects in collection set to “to” regions; free regions in collection set
•C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
© 2018 Arm Limited30
Concurrent Marking
SATB Algorithm
Logical snapshot of the heap
SATB marking guarantees that all garbage objects that are present at the start of the
concurrent marking phase will be identified by the snapshot
But, application mutates its object graph
Any new objects are considered live
For any reference update, the mutator needs to log the previous value in a log queue
This is enabled by a pre-write barrier
•C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
•https://www.jfokus.se/jfokus17/preso/Write-Barriers-in-Garbage-First-Garbage-Collector.pdf
© 2018 Arm Limited31
Barriers
SATB Pre-Write Barrier
The pseudo-code of the pre-write barrier for an assignment of the form x.f := y is:
if (marking_is_active) {
pre_val := x.f;
if (pre_val != NULL) {
satb_enqueue(pre_val);
}
}
•C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
© 2018 Arm Limited32
Barriers
Post Write Barrier
Consider the following assignment:
object.field = some_other_object
G1 GC will issue a write barrier after the reference is updated, hence the name.
G1 GC filters the need for a barrier by way of a simple check as explained below:
(&object.field XOR &some_other_object) >> RegionSize
If the check evaluates to zero, a barrier is not needed.
If the check != zero, G1 GC enqueues the card in the update log buffer
https://www.jfokus.se/jfokus17/preso/Write-Barriers-in-Garbage-First-Garbage-Collector.pdf
•C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
© 2018 Arm Limited33
STW Compaction
BodyHeader
A Java Object
Forwarding Pointer in Header
Pointer
Pointer to an
InstanceKlass
Mark Word
b b
GC workers compete to install the forwarding pointer
From source:
• An InstanceKlass is the VM level representation of a Java class. It contains all information needed for at class at
execution runtime.
• When marked the bits will be 11
© 2018 Arm Limited34
HotSpot Regionalized GCs:
Basic Differences - Shenandoah
© 2018 Arm Limited35
GC Phases of Marking & Compaction
Shenandoah GC
Initial Mark Mark objects directly reachable by the roots
Concurrent Marking Snapshot-at-the-beginning (SATB) algorithm
Final Marking Drain SATB buffers; traverse unvisited live objects; identify
collection set
Concurrent Cleanup Free completely free regions
Concurrent Compaction Move objects in collection set to “to” regions
Initial Update Reference Initialize the update reference phase
Concurrent Update Reference Scans the heap linearly; update any references to objects that
have moved
Final Update Reference Update roots to point to to-region copies
Concurrent Cleanup Free regions in collection set
https://wiki.openjdk.java.net/display/shenandoah/Main
© 2018 Arm Limited36
Concurrent Marking
SATB Algorithm
© 2018 Arm Limited37
Barriers
Pre-Write Barrier for Snapshot At the Beginning - Recap
Needed for all updates
Check if “marking-is-active”
SATB_enqueue the pre_val
•C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
© 2018 Arm Limited38
Concurrent Compaction
BodyHeader
A Java Object
Indirection
Pointer
Brooks Style Indirection Pointer
Forwarding pointer is placed before the object
Additional work of dereferencing per object
© 2018 Arm Limited39
Barriers
Read Barrier – For Concurrent Compaction
Here’s an assembly code snippet for reading a field:
mov 0x10(%rsi),%rsi ; *getfield value
Here’s what the snippet looks like with Shenandoah:
mov -0x8(%rsi),%rsi ; read of forwarding pointer at address object - 0x8
mov 0x10(%rsi),%rsi ; *getfield value
*Flood, Christine & Kennke, Roman & Dinn, Andrew & Haley, Andrew & Westrelin, Roland. (2016). Shenandoah: An
open-source concurrent compacting garbage collector for OpenJDK. 1-9. 10.1145/2972206.2972210.
© 2018 Arm Limited40
Barriers
Copying Write Barrier – For Concurrent Compaction
*Flood, Christine & Kennke, Roman & Dinn, Andrew & Haley, Andrew & Westrelin, Roland. (2016). Shenandoah: An
open-source concurrent compacting garbage collector for OpenJDK. 1-9. 10.1145/2972206.2972210.
Needed for all updates to ensure to-space invariant
Check if “evacuation_in_progress”
Check if “in_collection_set” and “not_yet_copied”
CAS (fwd-ptr(obj), obj, copy)
© 2018 Arm Limited41
HotSpot Regionalized GCs:
Basic Differences - Z
© 2018 Arm Limited42
GC Phases of Marking & Compaction
Z GC
Initial Mark Mark objects directly reachable by the roots
Concurrent Marking Striping - GC threads walk the object graph and mark
Final Marking Traverse unvisited live objects; weak root cleaning
Concurrent Prepare for Compaction Identify collection set; reference processing
Start Compaction Handles roots into the collection set
Concurrent Compaction Move objects in collection set to “to” regions
Concurrent Remap (done with Concurrent Marking of
next cycle since walks the object graph)
Fixup of all the pointers to now-moved objects
http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
© 2018 Arm Limited43
Core Concept
Metadata stores in the unused bits of the 64 bit pointers
Virtual address mapping/tagging
• Multi-mapping on x86-64
• Hardware support on SPARC, aarch64
http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
Colored Pointers
Object Address
041
Unused
M
a
r
k
e
d
0
M
a
r
k
e
d
1
R
e
m
a
p
p
e
d
F
i
n
a
l
i
z
a
b
l
e
4663
Object is known to be
marked?
Object is known to
not be pointing into
the relocation set?
Object is reachable
only through a
Finalizer?
© 2018 Arm Limited44
Concurrent Marking
Striping
Heap divided into logical stripes
GC threads work on their own stripe
Minimizes shared state
Load barrier to detect loads of non-marked object pointers
Concurrent reference processing
Thread local handshakes
http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
Heap
GC
Thread0
GC
Thread1
GC
Threadn
…
0 1 … n 0 1 … n 0 1 … n
Stripe0 Stripe1 Stripen
© 2018 Arm Limited45
Barriers
Read Barrier – For References
Update a “bad” reference to a “good” reference
Can be self-healing/repairing barrier when updates the source memory location
Imposes a set of invariants –
“All visible loaded reference values will be safely “marked through” by the
collector, if they haven’t been already.
All visible loaded reference values point to the current location of the safely
accessible contents of the target objects they refer to.”
Tene, G.; Iyengar, B. & Wolf, M. (2011), C4: The Continuously Concurrent Compacting Collector, in 'Proceedings of the
international symposium on Memory management' , ACM, New York, NY, USA , pp. 79--88 .
© 2018 Arm Limited46
Example
Object o = obj.fieldA; // Loading an object reference from heap
load_barrier(register_for(o), address_of(obj.fieldA));
if (o & bad_bit_mask) {
slow_path(register_for(o),
address_of(obj.fieldA)); }
© 2018 Arm Limited47
Example
mov 0x20(%rax), %rbx // Object o = obj.fieldA;
test %rbx, (0x16)%r15 // Bad color?
jnz slow_path // Yes -> Enter slow path and mark/relocate/remap,
// adjust 0x20(%rax) and %rbx
http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
© 2018 Arm Limited48
Concurrent Compaction
Load barrier to detect object pointers into the collection set
Can be self-healing
Off-heap forwarding tables enable to immediately release and reuse virtual and physical
memory
http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
Off-Heap Forwarding Tables
© 2018 Arm Limited49
Further Reading
https://www.youtube.com/watch?v=VCeHkcwfF9Q
https://www.usenix.org/legacy/events/vee05/full_papers/p46-click.pdf
http://mail.openjdk.java.net/pipermail/zgc-dev/2017-December/000047.html
http://hg.openjdk.java.net/zgc/zgc/file/ffab403eaf14/src/hotspot/share/gc/z/zBarrier.cpp
https://wiki.openjdk.java.net/display/zgc/Main
The Cloud to Edge Infrastructure Foundation
for a World of 1T Intelligent Devices
Thank You!

Weitere ähnliche Inhalte

Was ist angesagt?

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...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...Monica Beckwith
 
Game of Performance: A Song of JIT and GC
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
 
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...Monica Beckwith
 
OpenJDK Concurrent Collectors
OpenJDK Concurrent CollectorsOpenJDK Concurrent Collectors
OpenJDK Concurrent CollectorsMonica Beckwith
 
Applying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBBApplying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBBMonica Beckwith
 
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
 
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanJimin Hsieh
 
SFO15-110: Toolchain Collaboration
SFO15-110: Toolchain CollaborationSFO15-110: Toolchain Collaboration
SFO15-110: Toolchain CollaborationLinaro
 
Recent Changes and Challenges for Future Presto
Recent Changes and Challenges for Future PrestoRecent Changes and Challenges for Future Presto
Recent Changes and Challenges for Future PrestoKai Sasaki
 
TSC BoF: OSS Toolchain Discussion - SFO17-409
TSC BoF: OSS Toolchain Discussion - SFO17-409TSC BoF: OSS Toolchain Discussion - SFO17-409
TSC BoF: OSS Toolchain Discussion - SFO17-409Linaro
 
SFO15-102:ODP Project Update
SFO15-102:ODP Project UpdateSFO15-102:ODP Project Update
SFO15-102:ODP Project UpdateLinaro
 
HKG15-110: ODP Project Update
HKG15-110: ODP Project UpdateHKG15-110: ODP Project Update
HKG15-110: ODP Project UpdateLinaro
 
It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15
It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15
It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15Wolfgang Weigend
 
Cadence: The Only Workflow Platform You'll Ever Need
Cadence: The Only Workflow Platform You'll Ever NeedCadence: The Only Workflow Platform You'll Ever Need
Cadence: The Only Workflow Platform You'll Ever NeedMaxim Fateev
 
Python Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on FlinkPython Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on FlinkAljoscha Krettek
 
LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing John Nestor
 

Was ist angesagt? (20)

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...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
 
Game of Performance: A Song of JIT and GC
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
 
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
 
OpenJDK Concurrent Collectors
OpenJDK Concurrent CollectorsOpenJDK Concurrent Collectors
OpenJDK Concurrent Collectors
 
Applying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBBApplying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBB
 
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.
 
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
 
SFO15-110: Toolchain Collaboration
SFO15-110: Toolchain CollaborationSFO15-110: Toolchain Collaboration
SFO15-110: Toolchain Collaboration
 
Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
 
Tuning the g1gc
Tuning the g1gcTuning the g1gc
Tuning the g1gc
 
Trouble with memory
Trouble with memoryTrouble with memory
Trouble with memory
 
Recent Changes and Challenges for Future Presto
Recent Changes and Challenges for Future PrestoRecent Changes and Challenges for Future Presto
Recent Changes and Challenges for Future Presto
 
TSC BoF: OSS Toolchain Discussion - SFO17-409
TSC BoF: OSS Toolchain Discussion - SFO17-409TSC BoF: OSS Toolchain Discussion - SFO17-409
TSC BoF: OSS Toolchain Discussion - SFO17-409
 
SFO15-102:ODP Project Update
SFO15-102:ODP Project UpdateSFO15-102:ODP Project Update
SFO15-102:ODP Project Update
 
HKG15-110: ODP Project Update
HKG15-110: ODP Project UpdateHKG15-110: ODP Project Update
HKG15-110: ODP Project Update
 
It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15
It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15
It's a JDK- Jungle Out There – JDK 15 and OpenJDK 15
 
Cadence: The Only Workflow Platform You'll Ever Need
Cadence: The Only Workflow Platform You'll Ever NeedCadence: The Only Workflow Platform You'll Ever Need
Cadence: The Only Workflow Platform You'll Ever Need
 
Python Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on FlinkPython Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on Flink
 
LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing
 
Scaling i/o bound Microservices
Scaling i/o bound MicroservicesScaling i/o bound Microservices
Scaling i/o bound Microservices
 

Ähnlich wie OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS

Z Garbage Collector
Z Garbage CollectorZ Garbage Collector
Z Garbage CollectorDavid Buck
 
G1 collector and tuning and Cassandra
G1 collector and tuning and CassandraG1 collector and tuning and Cassandra
G1 collector and tuning and CassandraChris Lohfink
 
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...Flink Forward
 
Tuning Flink For Robustness And Performance
Tuning Flink For Robustness And PerformanceTuning Flink For Robustness And Performance
Tuning Flink For Robustness And PerformanceStefan Richter
 
Demystifying Garbage Collection in Java
Demystifying Garbage Collection in JavaDemystifying Garbage Collection in Java
Demystifying Garbage Collection in JavaIgor Braga
 
Understanding Garbage Collection
Understanding Garbage CollectionUnderstanding Garbage Collection
Understanding Garbage CollectionDoug Hawkins
 
Understanding Garbage Collection Using Automatic Memory Management
Understanding Garbage Collection Using Automatic Memory ManagementUnderstanding Garbage Collection Using Automatic Memory Management
Understanding Garbage Collection Using Automatic Memory ManagementzuluJDK
 
Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...
Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...
Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...NodejsFoundation
 
Low pause GC in HotSpot
Low pause GC in HotSpotLow pause GC in HotSpot
Low pause GC in HotSpotjClarity
 
sta slide ref.pdf
sta slide ref.pdfsta slide ref.pdf
sta slide ref.pdfquandao25
 
Scale Relational Database with NewSQL
Scale Relational Database with NewSQLScale Relational Database with NewSQL
Scale Relational Database with NewSQLPingCAP
 
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...confluent
 
Decentralized Evolution and Consolidation of RDF Graphs
Decentralized Evolution and Consolidation of RDF GraphsDecentralized Evolution and Consolidation of RDF Graphs
Decentralized Evolution and Consolidation of RDF GraphsAksw Group
 
How YugaByte DB Implements Distributed PostgreSQL
How YugaByte DB Implements Distributed PostgreSQLHow YugaByte DB Implements Distributed PostgreSQL
How YugaByte DB Implements Distributed PostgreSQLYugabyte
 
Garbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVMGarbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVMjaganmohanreddyk
 
An introduction to G1 collector for busy developers
An introduction to G1 collector for busy developersAn introduction to G1 collector for busy developers
An introduction to G1 collector for busy developersSanjoy Kumar Roy
 

Ähnlich wie OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS (20)

Z Garbage Collector
Z Garbage CollectorZ Garbage Collector
Z Garbage Collector
 
ZGC-SnowOne.pdf
ZGC-SnowOne.pdfZGC-SnowOne.pdf
ZGC-SnowOne.pdf
 
G1 collector and tuning and Cassandra
G1 collector and tuning and CassandraG1 collector and tuning and Cassandra
G1 collector and tuning and Cassandra
 
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
 
Tuning Flink For Robustness And Performance
Tuning Flink For Robustness And PerformanceTuning Flink For Robustness And Performance
Tuning Flink For Robustness And Performance
 
Demystifying Garbage Collection in Java
Demystifying Garbage Collection in JavaDemystifying Garbage Collection in Java
Demystifying Garbage Collection in Java
 
Understanding Garbage Collection
Understanding Garbage CollectionUnderstanding Garbage Collection
Understanding Garbage Collection
 
Understanding Garbage Collection Using Automatic Memory Management
Understanding Garbage Collection Using Automatic Memory ManagementUnderstanding Garbage Collection Using Automatic Memory Management
Understanding Garbage Collection Using Automatic Memory Management
 
Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...
Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...
Are your v8 garbage collection logs speaking to you?Joyee Cheung -Alibaba Clo...
 
Java GC, Off-heap workshop
Java GC, Off-heap workshopJava GC, Off-heap workshop
Java GC, Off-heap workshop
 
Low pause GC in HotSpot
Low pause GC in HotSpotLow pause GC in HotSpot
Low pause GC in HotSpot
 
sta slide ref.pdf
sta slide ref.pdfsta slide ref.pdf
sta slide ref.pdf
 
Lecture-5-STA.pdf
Lecture-5-STA.pdfLecture-5-STA.pdf
Lecture-5-STA.pdf
 
Scale Relational Database with NewSQL
Scale Relational Database with NewSQLScale Relational Database with NewSQL
Scale Relational Database with NewSQL
 
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...
 
Decentralized Evolution and Consolidation of RDF Graphs
Decentralized Evolution and Consolidation of RDF GraphsDecentralized Evolution and Consolidation of RDF Graphs
Decentralized Evolution and Consolidation of RDF Graphs
 
How YugaByte DB Implements Distributed PostgreSQL
How YugaByte DB Implements Distributed PostgreSQLHow YugaByte DB Implements Distributed PostgreSQL
How YugaByte DB Implements Distributed PostgreSQL
 
Garbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVMGarbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVM
 
An introduction to G1 collector for busy developers
An introduction to G1 collector for busy developersAn introduction to G1 collector for busy developers
An introduction to G1 collector for busy developers
 
Gc algorithms
Gc algorithmsGc algorithms
Gc algorithms
 

Mehr von Monica Beckwith

The ilities of software engineering.pptx
The ilities of software engineering.pptxThe ilities of software engineering.pptx
The ilities of software engineering.pptxMonica Beckwith
 
Intro to Garbage Collection
Intro to Garbage CollectionIntro to Garbage Collection
Intro to Garbage CollectionMonica Beckwith
 
Java Performance Engineer's Survival Guide
Java Performance Engineer's Survival GuideJava Performance Engineer's Survival Guide
Java Performance Engineer's Survival GuideMonica Beckwith
 
Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Monica Beckwith
 
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...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Monica Beckwith
 

Mehr von Monica Beckwith (7)

The ilities of software engineering.pptx
The ilities of software engineering.pptxThe ilities of software engineering.pptx
The ilities of software engineering.pptx
 
A G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptxA G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptx
 
QCon London.pdf
QCon London.pdfQCon London.pdf
QCon London.pdf
 
Intro to Garbage Collection
Intro to Garbage CollectionIntro to Garbage Collection
Intro to Garbage Collection
 
Java Performance Engineer's Survival Guide
Java Performance Engineer's Survival GuideJava Performance Engineer's Survival Guide
Java Performance Engineer's Survival Guide
 
Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!
 
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...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
 

Kürzlich hochgeladen

Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyAnusha Are
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 

Kürzlich hochgeladen (20)

Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS

  • 1. © 2018 Arm Limited1 OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS Monica Beckwith
  • 2. © 2018 Arm Limited2 About Me Java Champion, JavaOne Rock Star Regular speaker at various tech conferences Several published articles on topics including garbage collection, the Java memory model and others. Led Oracle’s Garbage First GC performance Java VM Performance Architect, Arm
  • 3. © 2018 Arm Limited3 Agenda What I’ll try to cover in the next ~50 minutes Part 1 – Groundwork & Commonalities Laying the Groundwork - Stop-the-world vs concurrent collection Heap layout – regions and generations Basic Commonalities – Copying collector – from and to spaces Regions - occupied and free Collection set and priority Part 2 – Introduction & Differences Introduction to G1, Shenandoah and Z GCs – Algorithm Basic Differences – GC phases Marking algorithm Barriers Copying
  • 4. © 2018 Arm Limited4 HotSpot Regionalized GCs: Groundwork
  • 5. © 2018 Arm Limited5 STW vs Concurrent
  • 6. © 2018 Arm Limited6 Application Threads STW
  • 7. © 2018 Arm Limited7 Application Threads Safepoint Requested STW
  • 8. © 2018 Arm Limited8 Application Threads Global or Thread Local? Safepoint Requested STW
  • 9. © 2018 Arm Limited9 Application Threads Safepoint Executed Time To Safepoint (TTSP) Safepoint Requested Global STW
  • 10. © 2018 Arm Limited10 Application Threads Safepoint Executed Time To Safepoint (TTSP) GC Threads Application Threads Safepoint Requested GC Completed Global STW
  • 11. © 2018 Arm Limited11 Application Threads Global or Thread Local? Safepoint Requested Thread Local Handshakes
  • 12. © 2018 Arm Limited12 Application Threads Safepoint Requested Thread Local Handshakes
  • 13. © 2018 Arm Limited13 Application Threads GC Threads Application Threads Safepoint Requested GC Completed Thread Local Handshakes Handshakes
  • 14. © 2018 Arm Limited14 Application Threads GC Threads Application Threads Safepoint Requested GC Completed Application Threads GC Threads Application Threads Safepoint Requested GC Completed Handshakes Thread Local Handshakes vs Global STW
  • 15. © 2018 Arm Limited15 Concurrent GC Application Threads GC Threads
  • 16. © 2018 Arm Limited16 Heap Layout Heap Z GC Shenandoah GC Young Generation G1 GC Old Generation
  • 17. © 2018 Arm Limited17 HotSpot Regionalized GCs: Basic Commonalities
  • 18. © 2018 Arm Limited18 Copying Collector aka Compacting Collector aka Evacuation HeapFrom Space To Space O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O GC ROOTS THREAD 1 STACK THREAD N STACK STATIC VARIABLES ANY JNI REFERENCES
  • 19. © 2018 Arm Limited19 O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O GC ROOTS THREAD 1 STACK THREAD N STACK O O O O O STATIC VARIABLES ANY JNI REFERENCES O OO O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Copying Collector aka Compacting Collector aka Evacuation
  • 20. © 2018 Arm Limited20 O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Copying Collector aka Compacting Collector aka Evacuation
  • 21. © 2018 Arm Limited21 Occupied and Free Regions O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O • List of free regions • In case of generational heap (like G1), the occupied regions could be young, old or humongous
  • 22. © 2018 Arm Limited22 Collection Priority and Collection Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO OOOO • Priority is to reclaim regions with most garbage • The candidate regions for collection/reclamation/relocation are said to be in a collection set • There are threshold based on how expensive a region can get and maximum regions to collect • Incremental collection aka incremental compaction or partial compaction • Usually needs a threshold that triggers the compaction • Stops after the desired reclamation threshold or free-ness threshold is reached • Doesn’t need to be stop-the-world
  • 23. © 2018 Arm Limited23 HotSpot Regionalized GCs: Introduction
  • 24. © 2018 Arm Limited24 Algorithm & Other Considerations Garbage Collectors G1 GC Shenandoah GC Z GC Regionalized? Yes Yes Yes Generational? Yes No No Compaction? Yes, STW, Forwarding address in header Yes, Concurrent, Brooks Style Indirection Pointer Yes, Concurrent, Colored Pointers Target Pause Times? 200ms 10ms 10ms Concurrent Marking Algorithm? SATB SATB Striped
  • 25. © 2018 Arm Limited25 Algorithm & Other Considerations Garbage Collectors G1 GC Shenandoah GC Z GC Regionalized? Yes Yes Yes Generational? Yes No No Compaction? Yes, STW, Forwarding address in header Yes, Concurrent, Brooks Style Indirection Pointer Yes, Concurrent, Colored Pointers Target Pause Times? 200ms 10ms 10ms Concurrent Marking Algorithm? SATB SATB Striped
  • 26. © 2018 Arm Limited26 Algorithm & Other Considerations Garbage Collectors G1 GC Shenandoah GC Z GC Regionalized? Yes Yes Yes Generational? Yes No No Compaction? Yes, STW, Forwarding address in header Yes, Concurrent, Brooks Style Indirection Pointer Yes, Concurrent, Colored Pointers Target Pause Times? 200ms 10ms 10ms Concurrent Marking Algorithm? SATB SATB Striped
  • 27. © 2018 Arm Limited27 Algorithm & Other Considerations Garbage Collectors G1 GC Shenandoah GC Z GC Regionalized? Yes Yes Yes Generational? Yes No No Compaction? Yes, STW, Forwarding address in header Yes, Concurrent, Brooks Style Indirection Pointer Yes, Concurrent, Colored Pointers Target Pause Times? 200ms 10ms 10ms Concurrent Marking Algorithm? SATB SATB Striped
  • 28. © 2018 Arm Limited28 HotSpot Regionalized GCs: Basic Differences – G1
  • 29. © 2018 Arm Limited29 GC Phases of Marking & Compaction G1 GC Gist Initial Mark Mark objects directly reachable by the roots Concurrent Root Region Scanning Since initial mark is piggy-backed on a young collection, the survivor regions need to be scanned Concurrent Marking Snapshot-at-the-beginning (SATB) algorithm Final Marking Drain SATB buffers; traverse unvisited live objects Cleanup Identify and free completely free regions, sort regions based on liveness and expense STW Compaction Move objects in collection set to “to” regions; free regions in collection set •C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
  • 30. © 2018 Arm Limited30 Concurrent Marking SATB Algorithm Logical snapshot of the heap SATB marking guarantees that all garbage objects that are present at the start of the concurrent marking phase will be identified by the snapshot But, application mutates its object graph Any new objects are considered live For any reference update, the mutator needs to log the previous value in a log queue This is enabled by a pre-write barrier •C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion. •https://www.jfokus.se/jfokus17/preso/Write-Barriers-in-Garbage-First-Garbage-Collector.pdf
  • 31. © 2018 Arm Limited31 Barriers SATB Pre-Write Barrier The pseudo-code of the pre-write barrier for an assignment of the form x.f := y is: if (marking_is_active) { pre_val := x.f; if (pre_val != NULL) { satb_enqueue(pre_val); } } •C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
  • 32. © 2018 Arm Limited32 Barriers Post Write Barrier Consider the following assignment: object.field = some_other_object G1 GC will issue a write barrier after the reference is updated, hence the name. G1 GC filters the need for a barrier by way of a simple check as explained below: (&object.field XOR &some_other_object) >> RegionSize If the check evaluates to zero, a barrier is not needed. If the check != zero, G1 GC enqueues the card in the update log buffer https://www.jfokus.se/jfokus17/preso/Write-Barriers-in-Garbage-First-Garbage-Collector.pdf •C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
  • 33. © 2018 Arm Limited33 STW Compaction BodyHeader A Java Object Forwarding Pointer in Header Pointer Pointer to an InstanceKlass Mark Word b b GC workers compete to install the forwarding pointer From source: • An InstanceKlass is the VM level representation of a Java class. It contains all information needed for at class at execution runtime. • When marked the bits will be 11
  • 34. © 2018 Arm Limited34 HotSpot Regionalized GCs: Basic Differences - Shenandoah
  • 35. © 2018 Arm Limited35 GC Phases of Marking & Compaction Shenandoah GC Initial Mark Mark objects directly reachable by the roots Concurrent Marking Snapshot-at-the-beginning (SATB) algorithm Final Marking Drain SATB buffers; traverse unvisited live objects; identify collection set Concurrent Cleanup Free completely free regions Concurrent Compaction Move objects in collection set to “to” regions Initial Update Reference Initialize the update reference phase Concurrent Update Reference Scans the heap linearly; update any references to objects that have moved Final Update Reference Update roots to point to to-region copies Concurrent Cleanup Free regions in collection set https://wiki.openjdk.java.net/display/shenandoah/Main
  • 36. © 2018 Arm Limited36 Concurrent Marking SATB Algorithm
  • 37. © 2018 Arm Limited37 Barriers Pre-Write Barrier for Snapshot At the Beginning - Recap Needed for all updates Check if “marking-is-active” SATB_enqueue the pre_val •C. Hunt, M. Beckwith, P. Parhar, B. Rutisson. Java Performance Companion.
  • 38. © 2018 Arm Limited38 Concurrent Compaction BodyHeader A Java Object Indirection Pointer Brooks Style Indirection Pointer Forwarding pointer is placed before the object Additional work of dereferencing per object
  • 39. © 2018 Arm Limited39 Barriers Read Barrier – For Concurrent Compaction Here’s an assembly code snippet for reading a field: mov 0x10(%rsi),%rsi ; *getfield value Here’s what the snippet looks like with Shenandoah: mov -0x8(%rsi),%rsi ; read of forwarding pointer at address object - 0x8 mov 0x10(%rsi),%rsi ; *getfield value *Flood, Christine & Kennke, Roman & Dinn, Andrew & Haley, Andrew & Westrelin, Roland. (2016). Shenandoah: An open-source concurrent compacting garbage collector for OpenJDK. 1-9. 10.1145/2972206.2972210.
  • 40. © 2018 Arm Limited40 Barriers Copying Write Barrier – For Concurrent Compaction *Flood, Christine & Kennke, Roman & Dinn, Andrew & Haley, Andrew & Westrelin, Roland. (2016). Shenandoah: An open-source concurrent compacting garbage collector for OpenJDK. 1-9. 10.1145/2972206.2972210. Needed for all updates to ensure to-space invariant Check if “evacuation_in_progress” Check if “in_collection_set” and “not_yet_copied” CAS (fwd-ptr(obj), obj, copy)
  • 41. © 2018 Arm Limited41 HotSpot Regionalized GCs: Basic Differences - Z
  • 42. © 2018 Arm Limited42 GC Phases of Marking & Compaction Z GC Initial Mark Mark objects directly reachable by the roots Concurrent Marking Striping - GC threads walk the object graph and mark Final Marking Traverse unvisited live objects; weak root cleaning Concurrent Prepare for Compaction Identify collection set; reference processing Start Compaction Handles roots into the collection set Concurrent Compaction Move objects in collection set to “to” regions Concurrent Remap (done with Concurrent Marking of next cycle since walks the object graph) Fixup of all the pointers to now-moved objects http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
  • 43. © 2018 Arm Limited43 Core Concept Metadata stores in the unused bits of the 64 bit pointers Virtual address mapping/tagging • Multi-mapping on x86-64 • Hardware support on SPARC, aarch64 http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf Colored Pointers Object Address 041 Unused M a r k e d 0 M a r k e d 1 R e m a p p e d F i n a l i z a b l e 4663 Object is known to be marked? Object is known to not be pointing into the relocation set? Object is reachable only through a Finalizer?
  • 44. © 2018 Arm Limited44 Concurrent Marking Striping Heap divided into logical stripes GC threads work on their own stripe Minimizes shared state Load barrier to detect loads of non-marked object pointers Concurrent reference processing Thread local handshakes http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf Heap GC Thread0 GC Thread1 GC Threadn … 0 1 … n 0 1 … n 0 1 … n Stripe0 Stripe1 Stripen
  • 45. © 2018 Arm Limited45 Barriers Read Barrier – For References Update a “bad” reference to a “good” reference Can be self-healing/repairing barrier when updates the source memory location Imposes a set of invariants – “All visible loaded reference values will be safely “marked through” by the collector, if they haven’t been already. All visible loaded reference values point to the current location of the safely accessible contents of the target objects they refer to.” Tene, G.; Iyengar, B. & Wolf, M. (2011), C4: The Continuously Concurrent Compacting Collector, in 'Proceedings of the international symposium on Memory management' , ACM, New York, NY, USA , pp. 79--88 .
  • 46. © 2018 Arm Limited46 Example Object o = obj.fieldA; // Loading an object reference from heap load_barrier(register_for(o), address_of(obj.fieldA)); if (o & bad_bit_mask) { slow_path(register_for(o), address_of(obj.fieldA)); }
  • 47. © 2018 Arm Limited47 Example mov 0x20(%rax), %rbx // Object o = obj.fieldA; test %rbx, (0x16)%r15 // Bad color? jnz slow_path // Yes -> Enter slow path and mark/relocate/remap, // adjust 0x20(%rax) and %rbx http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
  • 48. © 2018 Arm Limited48 Concurrent Compaction Load barrier to detect object pointers into the collection set Can be self-healing Off-heap forwarding tables enable to immediately release and reuse virtual and physical memory http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf Off-Heap Forwarding Tables
  • 49. © 2018 Arm Limited49 Further Reading https://www.youtube.com/watch?v=VCeHkcwfF9Q https://www.usenix.org/legacy/events/vee05/full_papers/p46-click.pdf http://mail.openjdk.java.net/pipermail/zgc-dev/2017-December/000047.html http://hg.openjdk.java.net/zgc/zgc/file/ffab403eaf14/src/hotspot/share/gc/z/zBarrier.cpp https://wiki.openjdk.java.net/display/zgc/Main
  • 50. The Cloud to Edge Infrastructure Foundation for a World of 1T Intelligent Devices Thank You!