So for about 3 months I’ve been mulling over an idea for how to create a garbage collection runtime in Rust. My first 1100 lines of Rust have been in prototyping parts and I finally feel that I have something worth discussing (and a decent handle on types and the borrow checker!)
A key reason we love Rust is that it doesn’t have a garbage collector that pauses execution ever, making it suitable for realtime applications. This proposed GC never pauses execution.
I invite you to read the RFC linked below and to discuss in the associated github issue.
Application threads maintain precise-rooted GC-managed pointers through smart pointers on the stack that write reference-count increments and decrements to a journal. The reference-count journal is read by a GC thread that maintains the actual reference count numbers in a cache of roots. When a reference count reaches zero, the GC thread moves the pointer to a heap cache data structure that is used by a tracing collector.
Because the GC thread has no synchronization between itself and the application threads besides the journal, all data structures that contain nested GC-managed pointers must be immutable in their GC-managed relationships: persistent data structures must be used to avoid data races.
I’m personally excited about this project and I appreciate any feedback and discussion!