一句话:提出 CIRC,将安全内存回收与引用计数结合,通过即时递归回收链式结构与即时递减,消除内存增长并缩小性能差距。
无托管语言中乐观并发的内存管理颇具挑战:安全内存回收(SMR)算法虽能解决问题但难以正确使用,自动引用计数接口更简单却效率不及 SMR。近期工作(Fast Reference Counter、OrcGC、Concurrent Deferred Reference Counting)借助 SMR 保护本地引用,通过推迟递减或回收获得显著性能提升,但延迟策略会导致链式结构回收缓慢、内存占用持续增长,且在更新密集负载下性能次优。本文提出并发即时引用计数(CIRC),将 SMR 与引用计数以新方式结合:仍采用延迟思想,但引入两种新算法——(1)通过跟踪每个对象的可达性,递归地立即回收链式结构;(2)立即执行递减,仅延迟回收。实验表明,CIRC 的内存占用不随时间增长,仅略高于底层 SMR,并进一步缩小了与底层 SMR 的性能差距,为无托管语言中高并发数据结构的自动安全内存管理提供了有前景的方案。
Memory management for optimistic concurrency in unmanaged programming languages is challenging. Safe memory reclamation (SMR) algorithms help address this, but they are difficult to use correctly. Automatic reference counting provides a simpler interface, but it has been less efficient than SMR algorithms. Recently, there has been a push to apply the optimizations used in garbage collectors for managed languages to elide reference count updates from local references. Notably, Fast Reference Counter, OrcGC, and Concurrent Deferred Reference Counting use SMR algorithms to protect local references by deferring decrements or reclamation. While they show a significant performance improvement, their use of deferral may result in growing memory usage due to slow reclamation of linked structures, and suboptimal performance in update-heavy workloads. We present Concurrent Immediate Reference Counting (CIRC), a new combination of SMR algorithms with reference counting. CIRC employs deferral like other modern methods, but it avoids their problems with novel algorithms for (1) immediately reclaiming linked structures recursively by tracking the reachability of each object, and (2) applying decrements immediately and deferring only the reclamation. Our experiments show that CIRC’s memory usage does not grow over time and is only slightly higher than the underlying SMR. Moreover, CIRC further narrows the performance gap between the underlying SMR, positioning it as a promising solution to safe automatic memory management for highly concurrent data structures in unmanaged languages.
@article{JungKPK24,
title = {Concurrent Immediate Reference Counting},
author = {Jaehwang Jung and Jeonghyeon Kim and Matthew J. Parkinson and Jeehoon Kang},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {PLDI},
year = {2024},
doi = {10.1145/3656383}
}