Article: "An Experiment in Garbage Collection"

Some time ago, in the summer after Rust went 1.0, I started a personal project to explore garbage collection in Rust. I stopped working on that project earlier this year but for anybody who might interested, I wrote up my experience here. The summary reads:

Mo-gc is an experiment in garbage collection written in the Rust programming language.

Instead of scanning the stack, the mutator writes reference count increments and decrements to a journal. The journal is read concurrently by a garbage collection thread that keeps a map of objects and their absolute reference counts. The object map is divided into young and mature generations and collection is done with parallellized mark and sweep phases.

The journal is a type of snapshot-at-beginning write barrier and this project was an experiment in the feasibility, limitations and scalability of this approach.

In brief conclusion, this project was ambitions and fell short but I learned some of the hard lessons of garbage collector implementation.

This article traces my thought process and implementation from beginning to time of writing.

6 Likes

Super happy to have helped spread the Unified Theory of GC paper a little bit! I never miss an opportunity to tell people about it :wink:

Only halfway through this piece, but I'm really enjoying it so far!

1 Like

You almost assuredly are also interested in "Rust as a Language for High Performance GC Implementation" and its source code.

Yeah, I have seen that but haven't had the energy to really grok it after the let down of my own project feeling like a fail :worried: (which I know it wasn't, I learned stuff that I wouldn't have if I'd done everything right the first time!)