7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
1/47
1Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Distributed Garbage Collection for
Wide Area Replicated Memory
from Alfonso Snchez, Lus Veiga, Paulo Ferreira
presented by Andrea Rezzonico
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
2/47
2Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Overview
1.Introduction
2.Memory Model
3.Algorithm4.Example
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
3/47
3Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Introduction
local root
x
z
y
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
4/47
4Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Introduction (2)
local root
x
z
y
y is not reachable from the process's local root
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
5/47
5Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Introduction (3)
local root
x
z
y
other processes may have a reference to y
local root
w
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
6/47
6Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Current Solutions
Distributed reference counting
Problem with cycles
Reference listing
Mark & sweep
count = 1
count = 1
What happen if we allow object replication?
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
7/47
7Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Replication
local root
z
local root
x
local root
x
Mark & sweep consider z garbage
process i process j
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
8/47
8Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Replication (2)
local root
z
local root
x
local root
x
but after a propagation z is reachable
propagate(x)i->j
process i process j
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
9/47
9Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Motivation
Shortcomings of Current Solutions
Replication is not considered
Constraints on scalability
Solution
Deals with replication
Does not impose constraints on scalability
It is indipendent of the used coherence protocol Does not deal with failures (i.e. communication failures)
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
10/47
10Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Overview
1.Introduction
2.Memory Model
3.Algorithm4.Example
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
11/47
11Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
WARM Model
Several communicating processes
Memory
Mutator: modify the reference graph throught
assignment (i)
Coherence engine: propagte the object replicas to
keep them coherent (propagate(y)i->j
)
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
12/47
12Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
What is Garbage?
local root
z
local root
x
local root
x
process i process j
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
13/47
13Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
What is Garbage? (2)
Unreachable objects are considered garbage
Union RuleA target object z is considered
unreachable only if the union of all
the replicas of the source objects
do not refer to it.
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
14/47
14Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Overview
1.Introduction
2.Memory Model
3.Algorithm
4.Example
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
15/47
15Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Data Structures
stub (OutRef, SourceObj, Scion, Chain)
scion (InRef, Stub, Chain)
local root
z
local root
x
process i
process j
Z
Z
scionstub
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
16/47
16Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Data Structures (2)
inPropList / outPropList
(propObj, propProc, sentUmess/recUmess)
process i
local root
process j
local root
process k
local root
x x
z
inPropList outPropList
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
17/47
17Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Data Structures (3)
inPropList / outPropList
(propObj, propProc, sentUmess/recUmess)
process i
local root
process j
local root
process k
local root
x x
z
inPropList outPropList
x j 0 x i 0
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
18/47
18Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Garbage Collector Root
Local root (stacks and static variables)
Set of scions
inPropList
outPropList
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
19/47
19Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Messages
unreachable
object replica is reachable only from the inPropList
process i
local root
process j
local root
x x
inPropList outPropList
x i 0x j 0
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
20/47
20Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Messages (2)
unreachable
object replica is reachable only from the inPropList
process i
local root
process j
local root
x x
inPropList outPropList
x i 1x j 1
unreachable(x)
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
21/47
21Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Messages (3)
reclaim
all object replicas are reachable only from the inPropList
process ilocal root
process j
local rootx
x
inPropList
outPropList
x i 1
x j 1
process k
local root
x
inPropList
x j 1
x k1
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
22/47
22Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Messages (4)
reclaim
all object replicas are reachable only from the inPropList
process ilocal root
process j
local rootx
x
inPropList
outPropList
x j 1
process k
local root
x
inPropList
x j 1
reclaim(x)
reclaim(x)
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
23/47
23Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Messages (5)
newSetStubs
when a new set of stubs is available
process i
local root
process j
local root
y
x
y
y
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
24/47
24Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Messages (6)
newSetStubs
when a new set of stubs is available
process i
local root
process j
local root
y
x
y
y
newSetStubs
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
25/47
25Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Messages (7)
newSetStubs
when a new set of stubs is available
process i
local root
process j
local root
y
x
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
26/47
26Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
DGC Algorithm
Local Collector
Starts the trace from the process's local root, the set of scions,
the inPropList and the outPropList
For every outgoing inter-process reference a stub is createdand added to the new set of stub
For objects reachable only from the inPropList an
unreachable message is sent and the sentUmess bit is set
For objects reachable only from the outPropList for which an
unreachable message from all process was received a
reclaim message is sent
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
27/47
27Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
DGC Algorithm (2)
Distributed Collector
Does not require waiting for replicas to be coherent
From time to time a newSetStubs message is sent to the
processes holding the scions corresponding to the stubs in theprevious stub set
unreachable message received
set recUmess bit
reclaimmessage received
delete the corresponding entry in the inPropList
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
28/47
28Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Overview
1.Introduction
2.Memory Model
3.Algorithm
4.Example
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
29/47
29Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
30/47
30Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (2)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4
Z
S3
Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
31/47
31Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (3)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4
Z
S3
Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
32/47
32Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (4)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4
Z
S3
Z
S6
Z
ZS5
S7Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
33/47
33Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (5)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4
Z
S3
Z
S6
Z
ZS5
S7Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
34/47
34Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (6)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4
Z
S3
Z
S6
Z
ZS5
S7Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
35/47
35Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (7)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4
Z
S3
Z
S6
Z
ZS5
S7Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
36/47
36Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (8)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4
Z
S3
Z
S6
Z
ZS5
S7Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
37/47
37Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Example (9)
propagate(y)j->i
i
propagate(x)i->j
j
propagate(y)j->i
i
xj
:= 0
xi
:= 0
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4Z
S3
Z
S6
Z
ZS5
S7Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
38/47
38Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Remarks
xiis reachable only
from the inPropList
xj
is reachable only
from the outPropList
zk
is reachable only
from the scion S1
no object can becollected yet
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 0
y j 0
x i 0
y i 0
inPropList outPropList
S4Z
S3
Z
S6
Z
ZS5
S7Z
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
39/47
39Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Collecting Garbage
LGC in process i
xiis reachable only
from the inPropList
an unreachable
message is sent
from i to j
the sentUmess bit
is set
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
x j 1
y j 0
x i 1
y i 0
inPropList outPropList
S4Z
S3
Z
S6
Z
ZS5
S7Z
unreachable(x)
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
40/47
40Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Collecting Garbage (2)
LGC in process j
xj
is reachable only
from the outPropList
delete the entry from
the outPropList in j
send a reclaim
message
delete the entry from
the inPropList in i
process i
local root
process j
local root
process k
local root
x
y
x
y
z
S1
S2
Z
Z
y j 0 y i 0
inPropList outPropList
S4Z
S3
Z
S6
Z
ZS5
S7Z
reclaim(x)
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
41/47
41Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Collecting Garbage (3)
LGC in process j
xj
is collected
S7 is deleted
a newSetStubs
message is sent
to process i
S6 is deleted
process i
local root
process j
local root
process k
local root
x
y y
z
S1
S2
Z
Z
y j 0 y i 0
inPropList outPropList
S4Z
S3
Z
S6
Z
ZS5
S7Z
newSetStubs
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
42/47
42Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Collecting Garbage (4)
LGC in process i
x is reclaimed in
process i
S5 and S4 are
deleted
a newSetStubs
message is sent to
process j
the distributed collector
deletes S3 in process j
process i
local root
process j
local root
process k
local root
y y
z
S1
S2
Z
Z
y j 0 y i 0
inPropList outPropList
S4Z
S3
Z
ZS5
newSetStubs
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
43/47
43Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Collecting Garbage (5)
LGC in process j
S2 is deleted
a newSetStubs
message is sent
from j to k
S1 is deleted
process i
local root
process j
local root
process k
local root
y y
z
S1
S2
Z
Z
y j 0 y i 0
inPropList outPropList
newSetStubs
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
44/47
44Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Collecting Garbage (6)
LGC in process k
z can now be
collected
process i
local root
process j
local root
process k
local root
y y
z
y j 0 y i 0
inPropList outPropList
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
45/47
45Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Conclusion
Advantages
Deals with replication
Scalability
Orthogonal to the coherence engine
Disadvantages
Not fault-tolerant
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
46/47
46Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Questions?
A di S f R l
7/29/2019 Seminar 15-06-2004 Sanchez DistributedGarbageCollection
47/47
47Concurrency Seminar: Distributed Garbage Collection for Wide Area Replicated Memory
Appendix 1: Safety Rules
Safety rule 1 (Clean Before Send Propagate)Before sending a propagate message for an object y from a
process j, y must be cleaned (i.e. it must be scanned for
references) and the corresponding scions created in j
Safety rule 2 (Clean Before Deliver Propagate)Before delivering a propagate message for an object y in a
process i, y must be cleaned (i.e. it must be scanned for
outgoing inter-process references) and the corresponding stubs
created in i, if they do not exist yet.