2) Serialize the object graph
3) Create and associate proxies
4) Replace original objects with proxies
The document proposes an application-level virtual memory system for object-oriented programs. It works by swapping out unused object graphs to secondary storage and replacing them with proxy objects in primary memory. When a proxy is accessed, its corresponding graph is swapped back in from secondary storage. Key aspects include assigning graph IDs, serializing graphs, creating associated proxy objects, and replacing original objects with proxies during swap out.
12. Context
• Object-oriented programming. Why?
Most modern and widespread.
Memory is usually automatically managed (GC).
• Dynamic languages. Why?
Powerful.
More and more used.
6
13. In this context of OOP,
is GC actually enough to
optimize memory
management?
7
14. % used objects ? % used memory ?
% unused objects ? % unused memory ?
8
55. Primary memory
Y A D
B C
E F
Memory occupied by graph of unused objects
Secondary memory
19
56. Primary memory
Y A D
B C
E F
Memory occupied by graph of unused objects
Secondary memory
Swap out
bytes (A,B,C,E,F)
19
57. Primary memory
Y A D
B C
facade objects
E F
Memory occupied by graph of unused objects
Secondary memory
Swap out
bytes (A,B,C,E,F)
19
58. Primary memory
Y A
Pa D
B C
Pc
facade objects
proxy E F
Memory occupied by graph of unused objects
Secondary memory
Swap out
bytes (A,B,C,E,F)
19
59. Primary memory
Y Pa D
Pc
facade objects
proxy
Memory occupied by graph of unused objects
Secondary memory
Swap out
bytes (A,B,C,E,F)
19
60. Primary memory
Y Pa D
Pc
facade objects
proxy
Secondary memory
bytes (A,B,C,E,F)
19
61. Primary memory
Y Pa D
Pc
facade objects
proxy
Secondary memory
bytes (A,B,C,E,F)
19
62. Primary memory
Y Pa D
Pc
facade objects
proxy
Secondary memory
Swap in
bytes (A,B,C,E,F)
19
63. Primary memory
Y A D
B C
facade objects
proxy E F
Secondary memory
19
64. How to efficiently detect
and manage facade objects?
• Back-pointers.
• Whole memory scan. Y A D
B C
E F
20
65. How to efficiently detect
and manage facade objects?
• Back-pointers.
• Whole memory scan. Y A D
B C
Marea provides an
E F
efficient solution.
20
66. Primary memory Swapping out
A D
GraphTable
B C
Secondary memory
21
67. Primary memory Swapping out
A D
GraphTable
B C
Secondary memory
21
68. Primary memory Swapping out
Graph ID: 42
A D
GraphTable
B C
Secondary memory 1) Assign graph ID
21
69. Primary memory Swapping out
Graph ID: 42
A D
GraphTable
B C
Secondary memory 1) Assign graph ID
2) Serialize the object graph
B’ A’ C’
1 2 3
42.swap
21
70. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
A Pa GraphTable
B C B Pb
Pb
42 1 C Pc
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’
1 2 3
42.swap
21
71. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
A Pa GraphTable
B C B Pb
Pb
42 1 C Pc
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’
1 2 3
42.swap
21
72. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
A Pa GraphTable
B C B Pb
Pb
42 1 C Pc
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’
1 2 3
42.swap
21
73. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
A Pa GraphTable
B C B Pb
Pb
42 1 C Pc
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
42.swap
21
74. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
A Pa GraphTable
B C B Pb
Pb
42 1 C Pc
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
42.swap
21
75. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
Pa A GraphTable
B C B Pb
Pb
42 1 C Pc
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
42.swap
21
76. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
Pa A GraphTable
B C Pb B
Pb
42 1 C Pc
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
42.swap
21
77. Primary memory Swapping out
Graph ID: 42
Pa Pc D
42 2 A 42 3
Pa A GraphTable
B C Pb B
Pb
42 1 Pc C
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
42.swap
21
78. Primary memory Swapping out
Graph ID: 42
Pa Pc 42 Pa Pb Pc
A D (weak array)
42 2 42 3
Pa A GraphTable
B C Pb B
Pb
42 1 Pc C
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Update GraphTable
42.swap
21
79. Primary memory Swapping out
Graph ID: 42
Pa Pc 42 Pa Pb Pc
A D (weak array)
42 2 42 3
Pa A GraphTable
B C Pb B
Pb
42 1 Pc C
proxiesDict
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Update GraphTable
6) GC runs
42.swap
21
80. Primary memory Swapping out
Pa Pc 42 Pa nil Pc
D (weak array)
42 2 42 3
Pa A GraphTable
Pb B
Pc C
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Update GraphTable
6) GC runs
42.swap
21
81. Primary memory Swapping out
Pa Pc 42 Pa nil Pc
D (weak array)
42 2 42 3
Pa A GraphTable
Pb B
Pc C
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Update GraphTable
6) GC runs
42.swap 7) Compact (optional)
21
82. Primary memory Swapping out
Pa Pc 42 Pa Pc
D (weak array)
42 2 42 3
Pa A GraphTable
Pb B
Pc C
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Update GraphTable
6) GC runs
42.swap 7) Compact (optional)
21
83. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 42 3 (weak array)
GraphTable
Secondary memory
B’ A’ C’
1 2 3
42.swap
22
84. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 42 3 (weak array)
GraphTable
Secondary memory 0) A proxy intercepts a message...
B’ A’ C’
1 2 3
42.swap
22
85. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 42 3 (weak array)
GraphTable
Secondary memory 0) A proxy intercepts a message...
B’ A’ C’
1 2 3
42.swap
22
86. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
B’ A’ C’
1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
B’ A’ C’
1 2 3
42.swap
22
87. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
88. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
89. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
90. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
91. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
92. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
93. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
Pa A’
B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
94. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
Pa A’
Pc C’ B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3
42.swap
22
95. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
Pa A’
Pc C’ B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3 3) Replace proxies with original objects
42.swap
22
96. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
A’ Pa
Pc C’ B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3 3) Replace proxies with original objects
42.swap
22
97. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
A’ Pa
C’ Pc B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3 3) Replace proxies with original objects
42.swap
22
98. Primary memory
Swapping in
Pa Pc D 42 Pa Pc
42 2 A’ 42 3 (weak array)
B’ C’ GraphTable
A’ Pa
C’ Pc B’ A’ C’
proxiesDict 1 2 3
materializedObjects
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
B’ A’ C’ materialized objects
1 2 3 3) Replace proxies with original objects
4) Clean
42.swap
22
99. Primary memory
Swapping in
Pa Pc D
42 2 A’ 42 3
B’ C’ GraphTable
C’ Pc
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
materialized objects
3) Replace proxies with original objects
4) Clean
22
100. Primary memory
Swapping in
A’ D
B’ C’ GraphTable
C’ Pc
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
materialized objects
3) Replace proxies with original objects
4) Clean
5) GC runs
22
101. Primary memory
Swapping in
A’ D
B’ C’ GraphTable
C’ Pc
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
materialized objects
3) Replace proxies with original objects
4) Clean
5) GC runs
6) Forward message to object 22
102. Primary memory
Swapping in
A’ D
B’ C’ GraphTable
C’ Pc
Secondary memory 0) A proxy intercepts a message...
1) Materialize the object graph
2) Associate proxies with
materialized objects
3) Replace proxies with original objects
4) Clean
5) GC runs
6) Forward message to object 22
103. Primary memory
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory
B’ A’ C’
1 2 3
42.swap
23
104. Primary memory
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory
B’ A’ C’
1 2 3
42.swap
23
105. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory 1) Assign graph ID
B’ A’ C’
1 2 3
42.swap
23
106. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory 1) Assign graph ID
2) Serialize the object graph
B’ A’ C’
1 2 3
42.swap
23
107. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory 1) Assign graph ID
2) Serialize the object graph
B’ A’ C’
1 2 3
42.swap
23
108. Primary memory
Graph ID: 43
Intersections...
Pc
A’ D
B’ C’ GraphTable
Secondary memory 1) Assign graph ID
2) Serialize the object graph
23
109. Primary memory
Graph ID: 43
Intersections...
Pc
A’ D
B’ C’ GraphTable
Secondary memory 1) Assign graph ID
2) Serialize the object graph
D’ C’
1 2
43.swap 23
110. Primary memory
Graph ID: 43
Intersections...
Pc
A’ D
B’ C’ GraphTable
Secondary memory 1) Assign graph ID
2) Serialize the object graph
...) as usually...
D’ C’
1 2
43.swap 23
111. Primary memory
Graph ID: 43
Intersections...
Pc
A’ D
B’ C’ GraphTable
Secondary memory 1) Assign graph ID
2) Serialize the object graph
...) as usually...
We don’tC’
D’ want to swap in a graph while
1 2
swapping out another one
43.swap 23
112. Primary memory
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory
B’ A’ C’
1 2 3
42.swap
24
113. Primary memory
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory
B’ A’ C’
1 2 3
42.swap
24
114. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory 1) Assign graph ID
B’ A’ C’
1 2 3
42.swap
24
115. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
GraphTable
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’
1 2 3
42.swap D’ Pc’
1 2
43.swap 24
116. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
Ppc Pd GraphTable
43 2 43 1
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3
42.swap D’ Pc’
1 2
43.swap 24
117. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
Ppc Pd GraphTable
43 2 43 1
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3 4) Replace original objects with proxies
42.swap D’ Pc’
1 2
43.swap 24
118. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
Ppc Pd GraphTable
43 2 43 1
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3 4) Replace original objects with proxies
42.swap D’ Pc’
1 2
43.swap 24
119. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
Ppc Pd GraphTable
43 2 43 1
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3 4) Replace original objects with proxies
42.swap D’ Pc’
1 2
43.swap 24
120. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
43 Pd Ppc
Ppc Pd GraphTable
43 1 (weak array)
43 2
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3 4) Replace original objects with proxies
42.swap 5) Update GraphTable
D’ Pc’
1 2
43.swap 24
121. Primary memory
Graph ID: 43
Intersections...
Pa Pc
Pa Pc D 42 (weak array)
42 2 42 3
43 Pd Ppc
Ppc Pd GraphTable
43 1 (weak array)
43 2
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3 4) Replace original objects with proxies
42.swap 5) Update GraphTable
D’ Pc’ 6) GC runs
1 2
43.swap 24
122. Primary memory
Intersections...
Pa nil
Pa 42 (weak array)
42 2
43 Pd nil
Pd GraphTable
43 1 (weak array)
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3 4) Replace original objects with proxies
42.swap 5) Update GraphTable
D’ Pc’ 6) GC runs
1 2
43.swap 24
123. Primary memory
Intersections...
Pa nil
Pa 42 (weak array)
42 2
43 Pd nil
Pd GraphTable
43 1 (weak array)
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
B’ A’ C’ 3) Create and associate proxies
1 2 3 4) Replace original objects with proxies
42.swap 5) Update GraphTable
D’ Pc’ 6) GC runs
1 2 7) Swap in graph 42
43.swap 24
124. Primary memory
Intersections...
nil
43 Pd nil
A’ Pd
43 1
GraphTable (weak array)
B’ C’
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
3) Create and associate proxies
4) Replace original objects with proxies
5) Update GraphTable
D’ Pc’ 6) GC runs
1 2 7) Swap in graph 42
43.swap 24
125. Primary memory
Intersections...
nil
43 Pd nil
A’ Pd
43 1
GraphTable (weak array)
B’ C’
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
3) Create and associate proxies
4) Replace original objects with proxies
5) Update GraphTable
D’ Pc’ 6) GC runs
1 2 7) Swap in graph 42
8) Swap in graph 43...
43.swap 24
126. Primary memory
Intersections...
nil
43 Pd nil
A’ Pd
43 1
GraphTable (weak array)
B’ C’
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
3) Create and associate proxies
4) Replace original objects with proxies
5) Update GraphTable
D’ Pc’ 6) GC runs
1 2 7) Swap in graph 42
8) Swap in graph 43...
43.swap 24
127. Primary memory
Intersections...
D’ nil
A’
GraphTable
B’ C’ Pc’
42 3
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
3) Create and associate proxies
4) Replace original objects with proxies
5) Update GraphTable
6) GC runs
7) Swap in graph 42
8) Swap in graph 43...
24
128. Primary memory
Intersections...
D’ nil
A’
GraphTable
B’ C’ Pc’
42 3
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
3) Create and associate proxies
4) Replace original objects with proxies
5) Update GraphTable
6) GC runs
7) Swap in graph 42
8) Swap in graph 43...
24
129. Primary memory
Intersections...
D’ nil
A’
GraphTable
B’ C’ Pc’
42 3
Secondary memory 1) Assign graph ID
2) Serialize the object graph (customize serializer)
3) Create and associate proxies
4) Replace original objects with proxies
5) Update GraphTable
6) GC runs
INCORRECT!!!
7) Swap in graph 42
8) Swap in graph 43...
24
130. Graph intersections
• Avoiding proxies for proxies (Ppc) does not solve
the problem either.
• Several scenarios for swapping in
swapped intersecting graphs.
25
131. Graph intersections
• Avoiding proxies for proxies (Ppc) does not solve
the problem either.
• Several scenarios for swapping in
swapped intersecting graphs.
Marea solves all these
scenarios and challenges.
25
132. Outline
1. Context, problem and introduction.
2. My proposal.
3. Validation.
4. Related work.
5. Implementation.
6. Conclusion and future work
26
133. Outline
1. Context, problem and introduction.
2. My proposal.
3. Validation.
4. Related work.
5. Implementation.
6. Conclusion and future work
26
134. Experiment
(web app + CMS) 1. We swapped out most classes
with their instances.
(standalone + lots of tools + large) 2. We navigated, used and tested
(174 pack. 1364 class. 121010 LOC) each application
1. Swapped in all needed
graphs for typical uses.
(mobile app) 2. Tests also for correctness.
3. We measured differences.
(infrastructure)
27
135. Original = 100% With Marea Measured minimun
100
75
% of memory
50
25
0
DBXTalk Moose DrGeo Pharo
28
136. Original = 100% With Marea Measured minimun
100
75
% of memory
50
25
0
DBXTalk Moose DrGeo Pharo
Marea released between 25%
and 40% of the used memory.
28
137. Original = 100% With Marea Measured minimun
100
75
% of memory
50
25
0
DBXTalk Moose DrGeo Pharo
Marea released between 25% There is still
and 40% of the used memory. room for improvement.
28
139. Speed overhead
• For typical uses is 0%. Swap in Swap out
• For non covered uses: 300
225
Time (ms)
150
75
0
51 236 777 5758 21753
Graph size (amount of objects)
29
140. Speed overhead
• For typical uses is 0%. Swap in Swap out
• For non covered uses: 300
225
Time (ms)
150
75
0
51 236 777 5758 21753
Graph size (amount of objects)
Swapping in is faster
than swapping out. 29
141. Speed overhead
• For typical uses is 0%. Swap in Swap out
• For non covered uses: 300
225
Time (ms)
150
75
0
51 236 777 5758 21753
Graph size (amount of objects)
Swapping in is faster The graph size has a small
than swapping out. impact in small/medium graphs.
29
142. Outline
1. Context, problem and introduction.
2. My proposal.
3. Validation.
4. Related work.
5. Implementation.
6. Conclusion and future work
30
143. Outline
1. Context, problem and introduction.
2. My proposal.
3. Validation.
4. Related work.
5. Implementation.
6. Conclusion and future work
30
144. Comparison criteria
• Efficient object-based swapping unit.
• Uniformity.
• Reversibility.
• Automatic swapping in.
• Automatic swapping out.
• Transparency.
• Controllability at the application level.
• Portability. 31
154. • An extensible, uniform and fast serializer.
• General-purpose.
• Used in research and industry.
• Integrated in Pharo 2.0 and ported to Squeak,
VisualWorks and Newspeak.
• ESUG Innovation Technology Awards 2011.
35
155. • An extensible, uniform and fast serializer.
• General-purpose.
• Used in research and industry.
• Integrated in Pharo 2.0 and ported to Squeak,
VisualWorks and Newspeak.
• ESUG Innovation Technology Awards 2011.
Martin Dias, Mariano Martinez Peck, Stéphane Ducasse and
Gabriela Arévalo. Fuel: A Fast General Purpose Object
Graph Serializer. Software: Practice and Experience, 2012.
35
156. • Proxify all kind of objects.
• Low memory footprint.
• Intercepting all messages.
• Clear division between proxies and handlers.
• General-purpose.
36
157. • Proxify all kind of objects.
• Low memory footprint.
• Intercepting all messages.
• Clear division between proxies and handlers.
• General-purpose.
[Martinez Peck 2012a] Mariano Martinez Peck, Noury Bouraqadi,
Stéphane Ducasse, Luc Fabresse and Marcus Denker. Ghost: A Uniform
and Lightweight Proxy Implementation. Science of Computer
Programming, 2012 (submitted + passed first review round).
36
158. Object replacement
• Provided by regular VM (#become:)
Specific to Smalltalk.
• Different implementations
Full memory scan in Pharo VM.
Object header swapping in VisualWorks VM.
Object tables’ entries swapping in Gemstone VM.
37
159. Outline
1. Context, problem and introduction.
2. My proposal.
3. Validation.
4. Related work.
5. Implementation.
6. Conclusion and future work
38
160. Outline
1. Context, problem and introduction.
2. My proposal.
3. Validation.
4. Related work.
5. Implementation.
6. Conclusion and future work
38
161. Conclusion
For an improved automatic memory
management we need:
GC
+
An application-level virtual memory
We propose
39
162. Results
Correct
• Facade objects.
• Graph intersection.
• Serializer and proxies for all type of objects.
• Proxies intercept all messages.
• Support proxies in primitives.
40
163. Results
Maximizes memory released
• Small proxies.
• Object graphs as swapping unit.
• Proxies only for facade objects.
Minimizes speed overhead
• Fast serialization.
• Fast detection of facade objects.
• Avoid unnecessary swap in.
41
168. Future Work
• Automatic graphs detection.
• Study possible integration with GC.
• Partial swap in.
44
169. List of publications
Conferences
[Dias 2011] Martin Dias, Mariano Martinez Peck, Stéphane Ducasse and Gabriela
Arévalo. Clustered Serialization with Fuel. In Proceedings of ESUG International Workshop
on Smalltalk Technologies (IWST 2011), Edinburgh, Scotland, 2011.
[Martinez Peck 2010a] Mariano Martinez Peck, Noury Bouraqadi, Marcus Denker,
Stéphane Ducasse and Luc Fabresse. Experiments with a Fast Object Swapper. In
Smalltalks 2010, Concepción del Uruguay, Argentina, 2010.
[Martinez Peck 2010b] Mariano Martinez Peck, Noury Bouraqadi, Marcus Denker,
Stéphane Ducasse and Luc Fabresse. Visualizing Objects and Memory Usage. In Smalltalks
2010, Concepción del Uruguay, Argentina, 2010.
[Martinez Peck 2011a] Mariano Martinez Peck, Noury Bouraqadi, Marcus Denker,
Stéphane Ducasse and Luc Fabresse. Efficient Proxies in Smalltalk. In Proceedings of ESUG
International Workshop on Smalltalk Technologies (IWST 2011), Edinburgh, Scotland, 2011.
[Martinez Peck 2011b] Mariano Martinez Peck, Noury Bouraqadi, Marcus Denker,
Stéphane Ducasse and Luc Fabresse. Problems and Challenges when Building a
Manager for Unused Objects. In Proceedings of Smalltalks 2011 International Workshop,
Bernal, Buenos Aires, Argentina, 2011.
45
170. List of publications
Journals
[Martinez Peck 2011c] Mariano Martinez Peck, Noury Bouraqadi, Stéphane Ducasse
and Luc Fabresse. Object Swapping Challenges: an Evaluation of ImageSegment.
Journal of Computer Languages, Systems and Structures, vol. 38, no. 1, pages 1–15, nov 2011.
[Dias 2012] Martin Dias, Mariano Martinez Peck, Stéphane Ducasse and Gabriela
Arévalo. Fuel: A Fast General Purpose Object Graph Serializer. Software: Practice and
Experience, 2012.
[Martinez Peck 2012a] Mariano Martinez Peck, Noury Bouraqadi, Stéphane Ducasse,
Luc Fabresse and Marcus Denker. Ghost: A Uniform and Lightweight Proxy
Implementation. Science of Computer Programming, 2012 (submitted + passed first
review round).
[Martinez Peck 2012b] Mariano Martinez Peck, Noury Bouraqadi, Marcus Denker,
Stéphane Ducasse and Luc Fabresse. Object-Based Virtual Memory Brought To The
Application Level. Journal of Object Technology, 2012 (submitted).
46
171. In summary...
• We implemented a novel and efficient
application-level virtual memory for object-
oriented systems.
• Almost no need from the VM and fully
implemented in the language side.
• Users can decide and influence what and when
to swap.
Thanks!
Mariano Martinez Peck
47
172.
173.
174. Fuel Features
• It is a fast, well-designed, concrete, general-
purpose and flexible binary serializer.
• Can serialize/materialize not only plain objects
but also classes, traits, methods, closures,
contexts, packages, etc.
• Support for global references.
• Large number of hooks: ignore certain instance
variables, substitute objects by others, post and
pre serialization and materialization actions.
• Supports class rename and class reshape.
175. Key Characteristics
• Pickle format.
• Objects grouped in clusters.
• Analysis phase before writing.
• Stack over recursion.
• Two phases for writing instances and
references.
• Iterative graph recreation.
176. Success stories
• Export and import of Moose models.
• Pier CMS persistency (and export/import)
• Backend of SandstoneDB, SimplePersistence and NoSQL databases.
• BioSmalltalk: serialize big DNA or proteins.
• PharoKernel regeneration and bootstrap (Hazelnut).
• Presenty UI and Gaucho frameworks.
• Revive test failures from Jenkins and materialize debuggers in
another image.
• Serialization for remote programming (Seamless).
• Tanker (export/import packages of code).
• Several commercial applications.
177. Traditional proxies
Usage of a minimal object together with an implementation of a
custom #doesNotUnderstand
ProtoObject
identityHash
pointersTo
nextObject
...
Proxy
target
doesNotUnderstand:
executeBeforeHandling
executeAfterHandling
178. Problems
#doesNotUnderstand: cannot be trapped like a
regular message.
Mix of handling procedure and proxy interception.
Only methods that are not understood are
intercepted.
No separation between proxies and handlers
This approach is not stratified
179. Ghost features
• It is stratified, it intercept all messages and
there are proxies and handlers.
• Uniform: it can proxy classes, methods, etc.
• Low memory footprint.
• Easy debugging.
180. Traditional Ghost
#doesNotUnderstand: #cannotInterpret: is
cannot be trapped like a trapped like a regular
regular message. message.
Mix of handling No mix of handling
procedure and proxy procedure and proxy
interception. interception.
Only methods that are
“All” methods are
not understood are
intercepted.
intercepted.
No separation between Clear separation between
proxies and handlers. proxies and handlers.
181. Classes with no
MethodDictionary
References Object
instance of
message send
lookup
subclass Proxy
cannotInterpret: aMessage
aProxy username 4: #cannotInterpret: lookup
1: #username send
ProxyTrap
methodDict := nil
aProxy
2: #aProxy lookup
3: Since the method dictionary was nil,
the VM sends #cannotInterpret to
the receiver but starting the lookup in the superclass
183. Conclusion
With a little bit of special support from the
VM (#cannotInterpret hook), we can have an
image-side proxy solution much better than
the classic #doesNotUnderstand:
[Martinez Peck 2012a] Mariano Martinez Peck, Noury Bouraqadi,
Stéphane Ducasse, Luc Fabresse and Marcus Denker. Ghost: A Uniform
and Lightweight Proxy Implementation. Science of Computer
Programming, 2012 (in submission, accepted with major revision).
184. ObjectTracer VM
• A Pharo Smalltalk virtual machine that
traces object usage.
• Let us query which objects has been used
and which ones have not.
http://ss3.gemstone.com/ss/ObjectUsageTracer.html
186. ImageSegment
(an object swapper for Squeak Smalltalk)
Good swapping unit: graphs.
It does not swap shared objects.
It cannot swap classes and methods.
It scans the whole memory twice for each graph.
Implemented in the VM side.
No support for graph intersection.
Mariano Martinez Peck, Noury Bouraqadi,Stéphane Ducasse
and Luc Fabresse. Object Swapping Challenges: an
Evaluation of ImageSegment. Journal of Computer Languages,
Systems and Structures, vol. 38, no. 1, pages 1–15, nov 2011.
189. Primary memory
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory
B’ A’ C’
1 2 3
42.swap
190. Primary memory
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory
B’ A’ C’
1 2 3
42.swap
191. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
B’ A’ C’
1 2 3
42.swap
192. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
B’ A’ C’
1 2 3
42.swap D’ Pc’
1 2
43.swap
193. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
Pd
43 1
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’
1 2 3
42.swap D’ Pc’
1 2
43.swap
194. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
Pd
43 1
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
42.swap D’ Pc’
1 2
43.swap
195. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
Pd
43 1
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
42.swap D’ Pc’
1 2
43.swap
196. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
Pd
43 1
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Store shared proxy
42.swap D’ Pc’
1 2
43.swap
197. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3
GraphTable
Pd
43 1
49194 Pc
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Store shared proxy
42.swap D’ Pc’
1 2
43.swap
198. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3 43 Pd Pc
GraphTable
Pd (weak array)
43 1
49194 Pc
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Store shared proxy
42.swap 6) Update GraphTable
D’ Pc’
1 2
43.swap
199. Primary memory
Graph ID: 43
Intersections...
Pa Pc
42 (weak array)
Pa Pc D
42 2 42 3 43 Pd Pc
GraphTable
Pd (weak array)
43 1
49194 Pc
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Store shared proxy
42.swap 6) Update GraphTable
D’ Pc’ 7) GC runs
1 2
43.swap
200. Primary memory
Intersections...
Pa Pc
42 (weak array)
Pa Pc
42 2 42 3 43 Pd Pc
GraphTable
Pd (weak array)
43 1
49194 Pc
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Store shared proxy
42.swap 6) Update GraphTable
D’ Pc’ 7) GC runs
1 2
43.swap
201. Primary memory
Intersections...
Pa Pc
42 (weak array)
Pa Pc
42 2 42 3 43 Pd Pc
GraphTable
Pd (weak array)
43 1
49194 Pc
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Store shared proxy
42.swap 6) Update GraphTable
D’ Pc’ 7) GC runs
1 2
8) Swap in graph 42
43.swap
202. Primary memory
Intersections...
Pa C’
42 (weak array)
Pc
42 3 43 Pd C’
A’ Pd
GraphTable (weak array)
43 1
B’ C’
49194 C’
SharedProxiesTable
(key: proxyID / value: object or proxy)
Secondary memory 1) Assign graph ID
2) Serialize the object graph
3) Create and associate proxies (not for proxies)
B’ A’ C’ 4) Replace original objects with proxies
1 2 3
5) Store shared proxy
42.swap 6) Update GraphTable
D’ Pc’ 7) GC runs
1 2
8) Swap in graph 42
43.swap