Constant-Time Reference Counting in Effekt
Efficient memory management is a central challenge for programs that allocate and discard large data structures at runtime. In garbage-collected languages, reclaiming such memory can introduce significant overhead, causing load spikes and observable pauses in execution. To address this issue, we investigate alternative memory management strategies using the Effekt programming language as an experimental platform.
We implement and evaluate both eager and constant-time reference counting, and additionally explore the integration of modern high-performance memory allocators, including mimalloc, jemalloc, and tcmalloc. Our evaluation shows that these state-of-the-art allocators are not suitable as complete replacements for Effekt’s allocation strategy. Furthermore, constant-time reference counting achieves up to 33.88% performance improvement over the vanilla implementation. While the performance difference between eager and constant-time reference counting is generally small, constant-time reference counting consistently performs slightly better across benchmarks. We also find that hybrid approaches combining a constant-time allocator with mimalloc, jemalloc, or tcmalloc lead to overall performance degradation.
Based on these results, we conclude that constant-time reference counting is the most effective and reliable memory management strategy for Effekt and recommend adopting it as the default approach.