![Page 1: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/1.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Conclusion
A Reference-Counting
Garbage Collection Algorithm
for Cyclical Functional Programming
Baltasar Trancón y Widemann
Universität Bayreuth, Germany
ISMM '08Tucson, Arizona2008�6�7/8
![Page 2: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/2.jpg)
RCGC4CFP
Trancón
Introduction
RC
History CRC
Special Cases
CFP
Algorithm
ConclusionReference Counting
&
Cycles
![Page 3: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/3.jpg)
RCGC4CFP
Trancón
Introduction
RC
History CRC
Special Cases
CFP
Algorithm
Conclusion
Reference Counting
In a Nutshell
I simple basic algorithmI count number of live references to a cellI reference count drops to zero =⇒ garbage
I often considered outdated, but not quite dead yet!
Famous Problem
I what about cycles?I reference count drops to zero ⇐= garbage
![Page 4: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/4.jpg)
RCGC4CFP
Trancón
Introduction
RC
History CRC
Special Cases
CFP
Algorithm
Conclusion
History of Cyclic Reference CountingThe Algorithm of Brownbridge (1985�88)
Principle
I partition references into strong and weak subsetI no cycle entirely strongI weak edges irrelevant for reachability (maintain!)
I collection based on strong count only
Advantages
I intuitively appealing
Disadvantages
I hard to get right, complex code
I e�ciency issues
![Page 5: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/5.jpg)
RCGC4CFP
Trancón
Introduction
RC
History CRC
Special Cases
CFP
Algorithm
Conclusion
History of Cyclic Reference CountingThe Algorithm of Lins, Martínez & Wachenchauzer (1990)
Principle
I detect cyclic garbage by �speculative deletion�
I revert if false positive
Advantages
I easy to understand & implement
I potential for optimization & heuristics
Disadvantages
I basic algorithm speculates too often, ine�cient
I thoroughly confounded by sharing
![Page 6: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/6.jpg)
RCGC4CFP
Trancón
Introduction
RC
History CRC
Special Cases
CFP
Algorithm
Conclusion
Common Special CasesAcyclic Data
Acyclic Data
I some data may not have cycles at all
statically by typedynamically by usage
I plain reference counting preferred
Fixed Data
I global constants & let bindings
I reachable by root references
I lower bound for lifetime known
![Page 7: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/7.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
ConclusionFunctional Programming
&
Cycles
![Page 8: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/8.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional Programming
In Common With Other FP Paradigms
I purely functional; immutable data
I free data types & recursion
I strict; no in�nite data
Speciality: Cycles
detect by searching the call stack for recurring inputs
handle by special values & operations
![Page 9: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/9.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingCycle Handling
Cycle Handling & Unfold
I build result top-down (destination passing)
I upon cycle, just copy previous result (ditto)
I e�ective for all primitively corecursive functions
Cycle Handling & Search
I traverse recursively
I upon cycle, return truth value immediately
I �xed point semantics
false least �xed pointtrue greatest �xed point
either intermediate �xed points
![Page 10: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/10.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
map (+5)
xs ys
![Page 11: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/11.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
map (+5)
xs ys
![Page 12: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/12.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
map (+5)
xs ys
![Page 13: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/13.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
map (+5)
map (+5)
xs ys
![Page 14: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/14.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
map (+5)
map (+5)
xs ys
![Page 15: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/15.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
map (+5)
map (+5)
xs ys
![Page 16: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/16.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
map (+5)
map (+5)
map (+5)
xs ys
![Page 17: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/17.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
map (+5)
map (+5)
map (+5)
xs ys
![Page 18: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/18.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
8
map (+5)
map (+5)
map (+5)
xs ys
![Page 19: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/19.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
8
map (+5)
map (+5)
map (+5)
map (+5)
xs ys
![Page 20: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/20.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
8
map (+5)
map (+5)
map (+5)
map (+5)
xs ys
![Page 21: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/21.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
8
9
map (+5)
map (+5)
map (+5)
map (+5)
xs ys
![Page 22: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/22.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
8
9
map (+5)
map (+5)
map (+5)
map (+5)
map (+5)
xs ys
![Page 23: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/23.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
8
9
map (+5)
map (+5)
map (+5)
map (+5)
map (+5)
xs ys
![Page 24: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/24.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Cyclical Functional ProgrammingExample: map
1
2
3
4
6
7
8
9
map (+5)
map (+5)
map (+5)
map (+5)
map (+5)
xs ys
![Page 25: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/25.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Implementation of CFPProgramming System
The Malice System
I virtual machine, supportsI destination passing & higher-order functionsI cycle detection & handling (ditto)
I interpreter & aot compiler
![Page 26: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/26.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Theory
Implementation
Algorithm
Conclusion
Implementation of CFPApplications
Cyclic Lists generalization of familiar list algorithms
I insert, delete, lengthI map, �lter, quicksort
Rationals generalization of school math algorithms
I arithmetics, orderI period detection
Algebraic Subtyping vtable-like dynamic encoding
I static recursive subtype checkingI dynamic (duck typing) access
Real-World Applications
![Page 27: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/27.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Wanted:
Reference-Counting Algorithm
![Page 28: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/28.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
3 2
11 3
Initial Situation
![Page 29: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/29.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
3 2
11 3
Initial Situation
![Page 30: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/30.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
2 2
11 3
Delete #1: Reachable, sharing
![Page 31: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/31.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
2 1
10 3
Delete #1: Reachable, sharing
![Page 32: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/32.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
2 1
10 3
Delete #1: Reachable, sharing
![Page 33: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/33.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
2 1
00 2
Delete #1: Reachable, sharing
![Page 34: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/34.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
2 1
00 2
Delete #1: Reachable, sharing
![Page 35: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/35.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
00 1
Delete #1: Reachable, sharing
![Page 36: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/36.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 2
01 1
Delete #1: Reachable, sharing
![Page 37: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/37.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 2
01 1
Delete #1: Reachable, sharing
![Page 38: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/38.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 2
11 2
Delete #1: Reachable, sharing
![Page 39: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/39.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 2
11 2
Delete #1: Reachable, sharing
![Page 40: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/40.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
2 2
11 3
Delete #1: Reachable, sharing
![Page 41: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/41.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 2
11 3
Delete #2: Reachable, di�erent way
![Page 42: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/42.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
10 3
Delete #2: Reachable, di�erent way
![Page 43: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/43.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
10 3
Delete #2: Reachable, di�erent way
![Page 44: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/44.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
00 2
Delete #2: Reachable, di�erent way
![Page 45: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/45.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
00 2
Delete #2: Reachable, di�erent way
![Page 46: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/46.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 1
00 1
Delete #2: Reachable, di�erent way
![Page 47: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/47.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 1
00 1
Delete #2: Reachable, di�erent way
![Page 48: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/48.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 1
00 1
Delete #2: Reachable, di�erent way
![Page 49: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/49.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 1
10 2
Delete #2: Reachable, di�erent way
![Page 50: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/50.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 1
10 2
Delete #2: Reachable, di�erent way
![Page 51: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/51.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
10 3
Delete #2: Reachable, di�erent way
![Page 52: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/52.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 2
11 3
Delete #2: Reachable, di�erent way
![Page 53: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/53.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 2
11 3
Delete #2: Reachable, di�erent way
![Page 54: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/54.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
11 3
Delete #3: Unreachable
![Page 55: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/55.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
01 2
Delete #3: Unreachable
![Page 56: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/56.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
1 1
01 2
Delete #3: Unreachable
![Page 57: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/57.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 1
01 1
Delete #3: Unreachable
![Page 58: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/58.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 0
00 1
Delete #3: Unreachable
![Page 59: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/59.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 0
00 1
Delete #3: Unreachable
![Page 60: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/60.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 0
00 1
Delete #3: Unreachable
![Page 61: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/61.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 0
00 1
Delete #3: Unreachable
![Page 62: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/62.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 0
00 1
Delete #3: Unreachable
![Page 63: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/63.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 0
00 1
Delete #3: Unreachable
![Page 64: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/64.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmMLW At Work
0 0
00 1
Delete #3: Unreachable
![Page 65: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/65.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmIdea #1
Idea #1 � Component Analysis
I consider strongly connected componentsI all cells in an SCC die togetherI only inter-SCC references count for reachability
I maintain separate inter/intra countsI inter count drops to zero =⇒ garbage
Problems
I inter-SCC references may point to distant members(#2)
I maintaining inter/intra classi�cation is hard
![Page 66: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/66.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmIdea #2
Idea #2 � Edge Coloring
I approximate inter/intra by maintained strong/weakpartition, à la Brownbridge
I strong ' inter
I choose invariants that are cheap to maintain
1. no cycle is entirely strong2. weak in + strong out =⇒ strong in
I maintain separate strong/weak countsI strong count drops to zero =⇒ garbage
![Page 67: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/67.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmInvariants
How To Maintain Invariant 1
I mutator creates references in three ways only
1. root =⇒ strong2. constructor argument =⇒ strong3. ditto =⇒ weak
How To Maintain Invariant 2
I deleting (strong) references may create violationsI weak in & no strong in & strong out
I rectify my making strong out references weakI propagate
![Page 68: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/68.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
2/1 2/0
1/01/0 3/0
Initial Situation
![Page 69: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/69.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
2/1 2/0
1/01/0 3/0
Initial Situation
![Page 70: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/70.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
1/1 2/0
1/01/0 3/0
Delete #1: Reachable, sharing
![Page 71: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/71.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
1/1 2/0
1/01/0 3/0
Delete #1: Reachable, sharing
![Page 72: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/72.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 2/0
1/01/0 3/0
Delete #2: Reachable, di�erent way
![Page 73: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/73.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 1/0
1/00/0 3/0
Delete #2: Reachable, di�erent way
![Page 74: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/74.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 1/0
1/00/0 3/0
Delete #2: Reachable, di�erent way
![Page 75: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/75.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 1/0
0/00/0 2/0
Delete #2: Reachable, di�erent way
![Page 76: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/76.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 1/0
0/00/0 2/0
Delete #2: Reachable, di�erent way
![Page 77: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/77.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 1/0
0/00/0 1/0
Delete #2: Reachable, di�erent way
![Page 78: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/78.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 1/0
0/00/0 1/0
Delete #2: Reachable, di�erent way
![Page 79: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/79.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 1/0
0/00/0 1/0
Delete #2: Reachable, di�erent way
![Page 80: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/80.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 1/0
0/00/0 1/0
Delete #2: Reachable, di�erent way
![Page 81: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/81.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 1/0
0/00/0 1/0
Delete #2: Reachable, di�erent way
![Page 82: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/82.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 1/0
1/00/0 2/0
Delete #2: Reachable, di�erent way
![Page 83: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/83.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 1/0
1/00/0 2/0
Delete #2: Reachable, di�erent way
![Page 84: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/84.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 1/0
1/00/0 3/0
Delete #2: Reachable, di�erent way
![Page 85: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/85.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 1/1
1/00/1 3/0
Delete #2: Reachable, di�erent way
![Page 86: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/86.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 1/1
1/00/1 3/0
Delete #2: Reachable, di�erent way
![Page 87: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/87.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 0/1
1/00/1 3/0
Delete #3: Unreachable
![Page 88: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/88.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 0/1
0/00/1 2/0
Delete #3: Unreachable
![Page 89: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/89.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/1 0/1
0/00/1 2/0
Delete #3: Unreachable
![Page 90: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/90.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/1
0/00/1 1/0
Delete #3: Unreachable
![Page 91: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/91.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 92: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/92.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 93: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/93.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 94: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/94.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 95: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/95.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 96: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/96.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 97: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/97.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 98: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/98.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 99: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/99.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmEC At Work
0/0 0/0
0/00/0 1/0
Delete #3: Unreachable
![Page 100: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/100.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
Deriving an AlgorithmIndependence
Independence Thesis
I edge coloring is independent of otheroptimizations/heuristics
I �push-out� should be possible
Case Study: Deletion Queue
I queue zero-count cell to defer speculation
I process one entry =⇒ others redundant
I combined with edge coloring in three hours
![Page 101: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/101.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationMeasurement
What And How To Measure
I no real-world implementation/application exists
I cannot measure runtime
Extend Idea From Original MLW Paper
I simulate & count traversal operations
I single (cyclical) algorithm, varying amount of cycles
I without queue & with di�erent sizes
I additionally measure green�blue ratio (overkill)
![Page 102: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/102.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationCharts: No Cycles in Input
0
5
10
15
20
25
0 1 2 5 10 20 50
KCal
ls
Queue Size
MLWEC
quicksort l where
l = [0..99]
![Page 103: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/103.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationCharts: Small Cycles in Input
0
2
4
6
8
10
12
14
0 1 2 5 10 20 50
KCal
ls
Queue Size
MLWEC
quicksort l where
l = [0..9] ++ (cycle [8,9])
![Page 104: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/104.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationCharts: Medium Cycles in Input
0
5
10
15
20
25
0 1 2 5 10 20 50
KCal
ls
Queue Size
MLWEC
quicksort l where
l = [0..9] ++ (cycle [5..9])
![Page 105: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/105.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationCharts: Large Cycles in Input
0
5
10
15
20
25
30
35
40
45
0 1 2 5 10 20 50
KCal
ls
Queue Size
MLWEC
quicksort l where
l = cycle [0..14]
![Page 106: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/106.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationCharts: Small Cycles in Input
0
5
10
15
20
25
0 1 2 5 10 20 50
Ove
rkill
Queue Size
MLWEC
quicksort l where
l = [0..9] ++ (cycle [8,9])
![Page 107: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/107.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationCharts: Medium Cycles in Input
0
2
4
6
8
10
12
14
16
18
0 1 2 5 10 20 50
Ove
rkill
Queue Size
MLWEC
quicksort l where
l = [0..9] ++ (cycle [5..9])
![Page 108: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/108.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationCharts: Large Cycles in Input
0 1 2 3 4 5 6 7 8 9
10
0 1 2 5 10 20 50
Ove
rkill
Queue Size
MLWEC
quicksort l where
l = cycle [0..14]
![Page 109: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/109.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Derivation
Evaluation
Conclusion
EvaluationSpecial Cases
Special Cases Come For Free!
Acyclic Input no weak references
Acyclic Types as above, statically
Global Data persistent strong references
I no speculation in either case
![Page 110: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/110.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Conclusion
Summary
Open Questions
Conclusions
![Page 111: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/111.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Conclusion
Summary
Open Questions
Conclusion
Summary
I CFP paradigm creates cycles in controlled way
I EC algorithm exploits control to speed up MLW
I 1�bit edge coloring, simple maintenance
I full algorithm & proof in paper
I combines with (some) other improvements
I applies where maintenance assumptions hold
![Page 112: RCGC4CFP rancónT Introduction A Reference-Counting CFP ... · Introduction CFP Algorithm Conclusion A Reference-Counting Garbage Collection Algorithm for Cyclical Functional Programming](https://reader034.vdocuments.us/reader034/viewer/2022050417/5f8cfb81086d024f2c486646/html5/thumbnails/112.jpg)
RCGC4CFP
Trancón
Introduction
CFP
Algorithm
Conclusion
Summary
Open Questions
Conclusion
Open Questions
I undo strong�weak conversion?
I more independent optimizations/heuristics?
I applicable/e�cient beyond toy examples?I real-world applications of CFP?I other applications with same mutator behavior?
Answers Welcome
I speci�cation & proof in the paper
I Java demo implementation available