Counting Immutable Beans: Reference Counting Optimized for Purely Functional Programming
Preprint
Abstract
Most functional languages rely on some garbage collection for automatic memory management. They usually eschew reference counting in favor of a tracing garbage collector, which has less bookkeeping overhead at runtime. On the other hand, having an exact reference count of each value can enable optimizations, such as destructive updates. We explore these optimization opportunities in the context of an eager, purely functional programming language. We propose a new mechanism for efficiently reclaiming memory used by nonshared values, reducing stress on the global memory allocator. We describe an approach for minimizing the number of reference counts updates using borrowed references and a heuristic for automatically inferring borrow annotations. We implemented all these techniques in a new compiler for an eager and purely functional programming language with support for multi-threading. Our preliminary experimental results demonstrate our approach is competitive and often outperforms state-of-the-art compilers.Keywords
All Related Versions
This publication has 16 references indexed in Scilit:
- Dynamic atomicity: optimizing swift memory management2017
- A metaprogramming framework for formal verificationProceedings of the ACM on Programming Languages, 2017
- Compiling without continuations2017
- Code Generation Using a Formal Model of Reference Counting2016
- The Lean Theorem Prover (System Description)2015
- The rust language2014
- Whole-program compilation in MLton2006
- Uniprocessor garbage collection techniques2005
- Minimizing reference count updating with deferred and anchored pointers for functional data structuresACM SIGPLAN Notices, 1994
- The essence of compiling with continuations1993