Ruby Performance Roundup: GC Tuning, MagLev, MacRuby

| by Werner Schuster Follow 7 Followers on Apr 16, 2009. Estimated reading time: 2 minutes |

The Garbage Collector in Ruby 1.8 has received a lot of attention in the past year. The developers behind Ruby Enterprise Edition (REE), have hacked the GC to share memory across processes (details in InfoQ's interview with the creators). REE has become a popular way to deploy and run Rails applications, with 37Signals and many others using it.
Recently the GC in REE was improved with a few bug fixes that removed sporadic freezes.
Users of a standard Ruby 1.8.x can also soon get some improvements from the MBARI patches that fix many GC problems and related memory leaks, and are now sponsored by EngineYard.

Evan Weaver gives GC tuning tips and recommends some patches that allow to monitor the GC. The results of the presented tuning:

Now the GC runs only every 13 requests, at a slightly higher cost, for a per-request cost of 0.009 seconds. This translates to a general speedup of 34%. The frequency of GC calls corresponds quite directly to the change in RUBY_GC_MALLOC_LIMIT, but if we increase it much more the memory usage balloons.

Another way to get more performance is to look at other Ruby implementations, such as JRuby which profits from the maturity of GCs in modern JVMs. Other implementations are aiming to improve the state of the art as well. Rubinius is improving steadily, and MacRuby has recently made news with its experimental branch which showed performance improvements. The work on the experimental branch is progressing:

- The compiler is now able (AFAIK) to compile all the language specs, so I guess it's now roughly complete.[..]
- Thanks to everything above, IRB is now running!

More improvements:

- Tail-call elimination was introduced. This optimization transforms recursive calls into local loops, in order to prevent stack overflows. [..]
- The LLVM IR interpreter was investigated in order to interpret faster #eval expressions. The result of this investigation has been committed and works pretty well with simple expressions, however it is not activated by default yet because of limitations when it comes to call the VM primitives. We will have to modify the LLVM interpreter a little bit in order to fully use it from MacRuby. This will be done in the near future.

Finally, GemStone's Ruby implementation MagLev is now in a private Alpha test, with a Beta coming in Q2. Now, compatibility (RubySpec) and benchmarking results are available at the MagLev website. Updates of the projects are also available on Twitter.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you