Title: Write Barrier Elision for Concurrent Garbage Collectors
1Write Barrier Elision for Concurrent Garbage
Collectors
-
-
- Martin T. Vechev
- Cambridge University
- David F. Bacon
- IBM T.J.Watson Research Center
2Write Barriers for Concurrent GC
- Mutator and Collector interleaved
- Mutator changes object graph
- Potential race conditions
- Write barriers a form of synchronization
- Between mutators and the collector.
3Can Synchronization Be Reduced?
?
write barrier
Concurrent Collector
write
Heap Connectivity Graph
Mutators
read
read
- Minimum information from a mutator to a
collector? - without compromising correctness?
- Can static analysis help?
- Can we discover dynamic opportunities?
4Outline
- The Synchronization Problem
- Elimination conditions
- Elimination opportunities (limit study)
- Elimination correlation
- Exploiting Order
- Conclusions and Future Work
5The Synchronization Problem
B
C
P1
A
Time
Collector Working
- Marks B as live
6The Synchronization Problem
B
B
P2
C
C
P1
P1
A
A
Time
Thread Working
Collector Working
- Installs P2
- Marks B as live
7The Synchronization Problem
B
B
B
P2
P2
C
C
C
P1
P1
A
A
A
Time
Thread Working
Thread Working
Collector Working
- Installs P2
- Deletes P1
- Marks B as live
8The Synchronization Problem
B
B
B
B
P2
P2
P2
C
?
C
C
P1
P1
A
A
A
A
Time
Thread Working
Thread Working
Collector Working
Collector Working
- C was not seen
- Reclaims C live!
- Installs P2
- Deletes P1
- Marks B as live
9The Synchronization Problem
A and B contain pointers to Object C
Point of Error
Memory Location
P1
A
P2
B
1
2
3
4
5
6
0
Time
10Types of Write Barriers
Steele Marks B (Source) for
rescanning
Dijkstra Mark C (new target) as live
Yuasa Mark C (old target) as live
B
B
B
B
P2
P2
P2
C
C
C
C
P1
P1
A
A
A
A
TIME
Collector Working
Thread Working
Thread Working
Collector Working
11Costs of Concurrent Write Barriers
- Mutator Overhead
- Direct Run-time Overhead (5-20)
- I-cache pollution by write barrier code
- Collector Overhead
- Process Write Barrier Information
- Space costs
- Sequential Store Buffer
- Increased Code Size
- Termination Issues
- Yuasa vs. Dijkstra/Steele
12Contributions
- Four Elimination Conditions a static analysis can
utilize. - Main idea based on pointer lifetimes.
-
- Two Covering conditions Apply to all barriers
- Two Allocation conditions Apply to incremental
barriers. - Limit study shows potential for barrier
elimination - For Yuasa, on average 83 can be eliminated
- For Dijkstra and Steele, on average 54 can be
eliminated - Correlation study between barrier elimination and
- Object Size
- Object Lifetime
- Program Locality
13Single Covering Condition
B
B
B
B
P2
C
C
C
C
P1
P1
P1
P1
A
A
A
A
TIME
Thread Working
Thread Working
Collector Working
Collector Working
Memory Location
- Key Observation
- P1s lifetime covers P2s
- Barriers on P2 are redundant
P1
A
P2
B
Time
1
2
3
14Single Covering Condition (Incremental)
Memory Location
Memory Location
Rescan Roots
L
H
A
A
H
H
B
B
Time
Time
4
4
1
2
3
1
2
3
15Single Covering Condition (Snapshot)
Memory Location
Memory Location
L
H
A
A
H
H
B
B
Time
Time
4
4
1
2
3
1
2
3
16Multiple Covering Condition
Memory Location
V
P1
A
P2
B
P3
C
Time
1
2
3
4
0
5
6
7
- Key Observation
- P1 together with a barrier on P2 form a virtual
pointer PV - Apply Single Covering to eliminate barriers on P3
17Multiple Covering Condition (Incremental)
Memory Location
Memory Location
L
L
A
A
L
H
B
B
H
H
C
C
Time
Time
4
4
1
2
3
1
2
3
18Multiple Covering Condition (Incremental)
Memory Location
Memory Location
H
H
A
A
L
H
B
B
H
H
C
C
Time
Time
4
4
1
2
3
1
2
3
19Multiple Covering Condition (Snapshot)
Memory Location
Memory Location
L
L
A
A
L
H
B
B
H
H
C
C
Time
Time
4
4
1
2
3
1
2
3
20Multiple Covering Condition (Snapshot)
Memory Location
Memory Location
H
H
A
A
L
H
B
B
H
H
C
C
Time
Time
4
4
1
2
3
1
2
3
21Single Allocation Condition
Memory Location
Key Observation H starts Inside New
pointer N
N
A
P2
B
Time
1
2
3
- Allocation conditions exploit Initial Root Set
Marking - Main idea At the time of a barrier, the object
is already marked - Only if allocating non-white (also trade off),
for Dijkstra/Steele only
22Multiple Allocation Condition
- Key Observation
- V N join L
- Apply SAC between V and H
Memory Location
V
N
A
L
B
H
C
Time
1
2
3
23Eliminating Null Pointer Stores
Dijkstra(destination, new_pointer) if
(Collector_Marking new_pointer !
NULL) store (new_pointer)
Yuasa(destination, old_pointer) if (
Collector_Marking old_pointer !
NULL) store (old_pointer)
- If old pointer is NULL, eliminate barrier
- Yuasa vs Steele/Dijskstra
- Yuasa good because of initialization
- Null stores are easier to eliminate
- But less payoff
24Evaluation Methodology
- Limit study based on elimination condition
- Shows potential for elimination
- Traces
- Jikes RVM 2.2.0
- Trace Events Allocation, Pointer Stores
- Application Objects Only
- Which benchmarks
- SpecJVM98 (-s100)
- Jolden
- Ipsixql
- Xalan
- Deltablue
25Barrier Elimination Potential Dijkstra / Steele
26Barrier Elimination Potential - Yuasa
27Time (MB) vs. Eliminated Yuasa Barriers
- Elimination is Periodic gt WB elimination
occurs in bursts
JAVAC
28Time (MB) vs. Eliminated Yuasa Barriers
- Elimination is Periodic gt WB elimination
occurs in bursts
DB
db
29Object Size (words) vs. Eliminated Yuasa Barriers
- Elimination is on Small objects
JAVAC
30Object Age vs. Eliminated Yuasa Barriers
- Elimination is mostly on Young objects (Log Y
scale)
JAVAC
31Object Age vs. Eliminated Yuasa Barriers
DB
32Further Write Barrier Elimination
- So far assumed collector sees pointers in any
order - Often, Collector order exists
- take advantage of it
-
- Main idea writes on the collector wave are safe.
- Cannot apply previous conditions
- Can eliminate more barriers
- Order extends to Lists, Queues, Trees (Needs
connectivity approximation)
33Single Object Scenarios (Order matters)
Broken Sequence
P2
P2
P2
B
B
B
B
C
C
C
?
P1
P1
Time
Thread Working
Thread Working
Collector Working
Collector Working
- Deletes P1
- B is partially
- scanned (gray)
- Reclaims live
- object C incorrectly
34Single Object Scenarios (Order matters)
Correct Sequence
B
B
B
B
C
C
C
C
P1
P1
P2
P2
P2
Collector Working
Thread Working
Thread Working
Collector Working
- Installs P2
- Deletes P1
- B is partially
- scanned (gray)
35Conclusions and Future Work
- Static Analysis Elimination Conditions
- An Upper Bound
- Hot Barrier Methods
- Yuasa Barriers seem superior to Dijkstra/Steele
- (study higher elimination vs. reduced floating
garbage) - Yuasa are harder to statically eliminate
- More conditions possible
- Requires formal reasoning
- Other elimination combinations possible
- Coverage (ownership) and Order can be exploited
further.