Rust as a language for high performance GC implementation
Authors
NICTA
Australian National University
Purdue University
Abstract
A high performance garbage collector is built upon performance-critical low-level code, typically exhibits multiple levels of concurrency, and is prone to subtle bugs. Implementing, debugging and maintaining such a collector can therefore be extremely challenging. The choice of implementation language is a crucial consideration when building a collector. Typically, the drive for performance and the need for efficient support of low-level memory operations leads to the use of low-level languages like C or C++, which offer little by way of safety and software engineering benefits. This risks undermining the robustness and flexibility of the collector design. Rust’s ownership model, lifetime specification, and reference borrowing deliver safety guarantees through a powerful static checker with little runtime overhead. These features should make Rust a compelling candidate for a collector implementation language, but they come with restrictions that threaten efficiency.
We describe our experience implementing an Immix garbage collector in Rust and C. We discuss the benefits of Rust, the obstacles encountered, and how we overcame them. We show that our Immix implementation has almost identical performance on micro benchmarks, compared to its implementation in C, and outperforms the popular BDW collector on the gcbench micro benchmark. We find that Rust’s safety features do not create significant barriers to implementing a high performance collector. Though memory managers are usually considered low-level, our high performance implementation relies on very little unsafe code, with the vast majority of the implementation benefiting from Rust’s safety. We see our experience as a compelling proof-of-concept of Rust as a garbage collection implementation language.
BibTeX Entry
@inproceedings{Lin_BHN_16, address = {Santa Barbara, California, USA}, author = {Lin, Yi and Blackburn, Steve and Hosking, Tony (Antony) and Norrish, Michael}, booktitle = {International Symposium on Memory Management}, doi = {10.1145/2926697.2926707}, keywords = {memory management, garbage collection, rust}, month = jun, pages = {89--98}, paperurl = {https://trustworthy.systems/publications/nicta_full_text/9260.pdf}, title = {Rust as a Language for High Performance {GC} Implementation}, year = {2016} }