GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing bugs.ruby-lang.org — Feature #20860: Merge Optional Experimental Feature MMTk into Ruby - Ruby - Ruby Issue Tracking System ProjectGeneralProfile
Actions
Feature #20860closedMerge Optional Experimental Feature MMTk into Ruby
Feature #20860:
Merge Optional Experimental Feature MMTk into Ruby
1
Added by peterzhu2118 (Peter Zhu) about 2 years ago. Updated almost 2 years ago. Status: Closed Assignee: - Target version: - Description GitHub PR: https://github.com/ruby/ruby/pull/11979 Summary¶In this ticket, we're proposing upstreaming the current MMTk implementation into the The current MMTk implementation uses the GC API and implements the NoGC and mark-sweep algorithms. The current implementation is, in many cases, slower than Ruby's default GC, but we have concrete steps to improve performance, which is discussed in the Next Steps section. Background¶In [Feature #20351] we introduced a mechanism to plug an external garbage collector into Ruby using a dynamic shared library and in [Feature #20470] we introduced an API for third-party garbage collectors to plug into Ruby. Using this API, we were able to demonstrate that we can plug NoGC (a GC that allocates but never collects) and a modified version of Ruby's garbage collector into Ruby. For the past few months, we've been implementing plugging MMTk into Ruby using this API. What's MMTk?¶MMTk is a framework that provides a wide variety of garbage collector implementations. Once a language integrates into their API, the language can use a wide variety of GC implementations, from basic algorithms such as mark-sweep (similar to Ruby's current GC), to more complex algorithms such as Immix its variants. Kunshan Wang is a researcher at Australian National University and he has been working on implementing Ruby with MMTk. His work is available as a fork of Ruby at mmtk/ruby with Rust bindings at mmtk/mmtk-ruby. Implementation¶Overview¶We've taken Kunshan's implementation and rewritten it using the GC API. Compared to Kunshan's original implementation, this makes the changes minimally invasive as it removes the need for MMTk specific code inside Ruby. Instead, all of the MMTk code lives inside of However, compared to Kunshan's implementation, we only support a subset of features and have inferior performance. Most notably, we currently only support NoGC (a GC that only allocates but never collects) and mark-sweep (which is similar to Ruby's current GC). We do not support the advanced copying GC that Kunshan's implementation supports, such as Immix. Using This Feature¶To use this feature, follow these steps:
You can also customize MMTk at runtime with the following environment variables:
Code Organization¶The code is organized into two parts: the C binding and the Rust binding. The C binding lives in The Rust binding lives in the mmtk-core is included as a dependency of the Rust binding and contains language agnostic implementations of various garbage collectors. At compile time, the Rust binding is statically linked to the C binding to form a shared object that can be dynamically loaded by Ruby. Why We Are Proposing to Upstream This Feature¶At this point, we have fully functional implementations of NoGC and mark-sweep algorithms. While we still have a long way to go to improve performance and implement more advanced algorithms (discussed in the Next Steps section), we would like to upstream this to improve collaboration with the Ruby core team and the Ruby community. This proposal is for an experimental feature and will not be enabled by default. For users that want to try out this feature, they will have to compile Ruby with the shared GC feature enabled, compile the Rust bindings, and compile the MMTk shared GC. Additionally, we do not ever anticipate replacing Ruby's default GC with MMTk but instead offer it as an alternative implementation. Ruby's default GC will always be the default GC due to its lack of external dependencies, versatility, and ease of use. As such, similar to YJIT, we will not be introducing a dependency on Rust for normal builds. Benchmarks and Analysis¶We ran yjit-bench (commit 1b298fa) on a Ubuntu 24.04 machine with an Intel Core Ultra 7 155H. Here are the benchmark results: The performance geometric mean is 0.28, so it is almost 4x slower than the default GC. We analyzed the railsbench benchmark, and we found clear reasons why it's slower:
These are some of the performance bottlenecks that we have identified and we have concrete steps on improving this in the section below. Next Steps¶Our current roadmap looks like the following:
Files
| ||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |