一句话:对 OpenJDK ZGC 做高层设计解析,并用 SPIN 模型解释 mutator 与 GC 线程的并发竞争及解决。
ZGC 是 OpenJDK 新增的现代非分代、基于区域、大部分并发、并行标记-搬移垃圾收集器,其 C++ 源码约 25 KLOC,阅读困难,底层实现细节容易掩盖核心概念。本文提供高层次但保留适度实现细节的说明,聚焦整体设计。为解释并发,构建 SPIN 模型,研究 mutator 与 GC 线程的竞争及 ZGC 的解决方式。该模型支持确定性和交互式学习,也便于原型化新想法与扩展。作者希望借此使 ZGC 成为未来 GC 研究的构建块,让基于其上的研究想法更易被工业采用,弥合 GC 研究中学术界与工业界的差距。
ZGC is a modern, non-generational, region-based, mostly concurrent, parallel, mark-evacuate collector recently added to OpenJDK. It aims at having GC pauses that do not grow as the heap size increases, offering low latency even with large heap sizes. The ZGC C++ source code is readily accessible in the OpenJDK repository, but reading it (25 KLOC) can be very intimidating, and one might easily get lost in low-level implementation details, obscuring the key concepts. To make the ZGC algorithm more approachable, this work provides a thorough description on a high-level, focusing on the overall design with moderate implementation details. To explain the concurrency aspects, we provide a SPIN model that allows studying races between mutators and GC threads, and how they are resolved in ZGC. Such a model is not only useful for learning the current design (offering a deterministic and interactive experience) but also beneficial for prototyping new ideas and extensions. Our hope is that our detailed description and the SPIN model will enable the use of ZGC as a building block for future GC research, and research ideas implemented on top of it could even be adopted in the industry more readily, bridging the gap between academia and industry in the context of GC research.
@article{paperbot1603,
title = {Deep Dive into ZGC: A Modern Garbage Collector in OpenJDK},
author = {Albert Mingkun Yang and Tobias Wrigstad},
journal = {ACM Transactions on Programming Languages and Systems},
volume = {44},
number = {4},
year = {2022},
doi = {10.1145/3538532}
}