Wei Fan, IBM T.J.Watson Joe McCloskey, US Department of Defense Philip Yu, IBM T.J.Watson
1 Write Barrier Elision for Concurrent Garbage Collectors Martin T. Vechev Cambridge University...
-
Upload
annabelle-kirkman -
Category
Documents
-
view
221 -
download
0
Transcript of 1 Write Barrier Elision for Concurrent Garbage Collectors Martin T. Vechev Cambridge University...
1
Write Barrier Elision for Concurrent Garbage Collectors
Martin T. Vechev
Cambridge University
David F. Bacon
IBM T.J.Watson Research Center
2
Write 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.
3
Can Synchronization Be Reduced?
• Minimum information from a mutator to a collector?– without compromising correctness?
• Can static analysis help?• Can we discover dynamic opportunities?
ConcurrentCollector
?
MutatorsHeap
Connectivity Graph
write
read
read
write barrier
4
Outline
• The Synchronization Problem
• Elimination conditions
• Elimination opportunities (limit study)
• Elimination correlation
• Exploiting Order
• Conclusions and Future Work
5
A
CB
P1
The Synchronization Problem
Time
Collector Working
- Marks B as live
6
A
CB
P1
The Synchronization Problem
A
CB
P1
P2
Time
Collector Working Thread Working
- Installs P2- Marks B as live
7
A
CB
P1
The Synchronization Problem
A
CB
P1
P2
A
CB P2
Time
Collector Working Thread Working Thread Working
- Installs P2 - Deletes P1- Marks B as live
8
A
CB
P1?
The Synchronization Problem
A
CB
P1
P2
A
CB P2
A
B P2
Time
Collector Working Thread Working Thread Working Collector Working
- Installs P2 - Deletes P1- Marks B as live - C was not seen- Reclaims C: live!
9
Time
MemoryLocation
A
B
P1
P2
1 2 3 4 5 60
A and B contain pointers to Object C
Point of Error
The Synchronization Problem
10
Types of Write Barriers
A
CB
P1A
CB
P1
P2
A
B P2
A
B P2
TIME
Collector Working Thread Working Thread Working Collector Working
C C
Steele
Marks B (Source) for rescanning
Dijkstra
Mark C (new target) as live
Yuasa
Mark C (old target) as live
11
Costs 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
12
Contributions
• Four Elimination Conditions a static analysis can utilize.– Main idea based on pointer lifetimes.
1. Two Covering conditions: Apply to all barriers
2. 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
13
Single Covering Condition
Time
MemoryLocation
1 2 3
A
B
P1
P2
Key Observation:
• P1’s lifetime covers P2’s • Barriers on P2 are redundant
A
CB
P1
A
CB
P1
P2
A
CB
A
B
TIME
Collector Working Thread Working Thread Working Collector Working
P1
CP1
14
Single Covering Condition (Incremental)
Time
MemoryLocation
1 2 3
A
B
L
H
RescanRoots
4
Time
MemoryLocation
1 2 3
A
B
H
H
4
15
Single Covering Condition (Snapshot)
Time
MemoryLocation
1 2 3
A
B
L
H
4
Time
MemoryLocation
1 2 3
A
B
H
H
4
16
Time
MemoryLocation
A
B
P1
P3
1 2 3 40
Multiple Covering Condition
P2
5 6 7
C
V
Key Observation :
• P1 together with a barrier on P2 form a virtual pointer PV• Apply Single Covering to eliminate barriers on P3
17
Multiple Covering Condition (Incremental)
Time
MemoryLocation
1 2 3
A
B
L
H
4
L
C
Time
MemoryLocation
1 2 3
A
B
L
H
4
H
C
18
Multiple Covering Condition (Incremental)
Time
MemoryLocation
1 2 3
A
B
H
H
4
L
C
Time
MemoryLocation
1 2 3
A
B
H
H
4
H
C
19
Multiple Covering Condition (Snapshot)
Time
MemoryLocation
1 2 3
A
B
L
H
4
L
C
Time
MemoryLocation
1 2 3
A
B
L
H
4
H
C
20
Multiple Covering Condition (Snapshot)
Time
MemoryLocation
1 2 3
A
B
H
H
4
L
C
Time
MemoryLocation
1 2 3
A
B
H
H
4
H
C
21
Single Allocation Condition
• 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
Time
Memory Location
1 2 3
A
B
N
P2
Key Observation :
H starts Inside ‘New’ pointer N
22
Multiple Allocation Condition
Key Observation :
• V = N join L• Apply SAC between V and H
Time
Memory Location
1 2 3
A
B
C
N
L
H
V
23
Eliminating Null Pointer Stores
• 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
Yuasa(destination, old_pointer) if ( Collector_Marking && old_pointer != NULL) store (old_pointer);
Dijkstra(destination, new_pointer) if (Collector_Marking && new_pointer != NULL) store (new_pointer);
24
Evaluation 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
25
Barrier Elimination Potential – Dijkstra / Steele
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%SCC SAC Null Remaining
26
Barrier Elimination Potential - Yuasa
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%SCC Null Remaining
27
Time (MB) vs. Eliminated Yuasa Barriers
• Elimination is Periodic => WB elimination occurs in bursts
0
2000
4000
6000
8000
10000
12000
14000
1476 3483 5488 7490 9493 11493 13498 15498
Time (MB allocated)
Eli
min
ate
d B
arr
iers
JAVAC
28
Time (MB) vs. Eliminated Yuasa Barriers
• Elimination is Periodic => WB elimination occurs in bursts
db
0
100000
200000
300000
400000
500000
6086 7268 8447 9755 11048 12371 13669 15030
Time (MB allocated)
Eli
min
ated
Bar
rier
s
DB
29
Object Size (words) vs. Eliminated Yuasa Barriers
• Elimination is on Small objects
0
300000
600000
900000
1200000
1500000
1800000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Object Size (words)
Elim
inat
ed B
arri
ers
JAVAC
30
Object Age vs. Eliminated Yuasa Barriers
• Elimination is mostly on Young objects (Log Y scale)
1
10
100
1000
10000
100000
1000000
0 10 20 30 40 50 60 70 80 90
Object Age (in MB)
Elim
inat
ed B
arri
ers
JAVAC
31
Object Age vs. Eliminated Yuasa Barriers
• An Exception
1
10
100
1000
10000
100000
0 2258 6687 8656 8856 9065 9265 9485 9689 9889
DB
32
Further 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)
33
Single Object Scenarios (Order matters)
CP1
?
Time
Collector Working Thread Working Thread Working Collector Working
-Installs P2 - Deletes P1-B is partially scanned (gray)
- Reclaims live object C incorrectly
CP1
P2
CP2 P2
Broken Sequence
B B B B
34
Single Object Scenarios (Order matters)
CP1
CP1
P2
CP2
C
Correct Sequence
Collector Working
Thread Working Thread Working Collector Working
- Installs P2 - Deletes P1- B is partiallyscanned (gray)
- C is NOT collected
B B B BP2
35
Conclusions 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.