Building the Next-Generation Garbage Collector in Ruby

Last year at RubyKaigi 2025, the Modular Garbage Collector feature in Ruby was introduced. With this feature, we shipped an alternative garbage collector using the Memory Management Toolkit (MMTk) framework. At the time, however, MMTk was significantly slower than the default garbage collector in Ruby.

Over the past year, the MMTk Ruby integration has been significantly improved and the performance is now on par with the default garbage collector. It now supports the Moving Immix garbage collection strategy, improved parallelism, and numerous optimizations.

In this talk, we will go over the Modular Garbage Collector feature and its differences with the default garbage collector, examine the techniques used to speed up the Ruby MMTk integration, and discuss how it can be improved further in the future.

  • Peter Zhu
    Peter Zhu

    Peter is a Ruby core committer and Staff Engineer at Figma. He works on improving the performance of Ruby and is currently working on Modular GC and the MMTk integration. He is the co-author of the Variable Width Allocation feature in Ruby, which improves Ruby's performance by optimizing the memory layout. He is also the author of ruby_memcheck, a gem used to find memory leaks in native gems and it has found memory leaks in popular gems such as Nokogiri, protobuf, gRPC, and liquid-c.