Rust as a language for high performance GC implementation

Authors

Yi Lin, Steve Blackburn, Tony Hosking and Michael Norrish

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, author = {Lin, Yi and Blackburn, Steve and Hosking, Tony (Antony) and Norrish, Michael}, doi = {10.1145/2926697.2926707}, month = jun, year = {2016}, keywords = {memory management, garbage collection, rust}, address = {Santa Barbara, California, USA}, title = {Rust as a Language for High Performance {GC} Implementation}, pages = {89--98}, booktitle = {International Symposium on Memory Management}, paperurl = {https://ts.data61.csiro.au/publications/nicta_full_text/9260.pdf} }

Download