REE can be easily installed in parallel to your existing Ruby interpreter, allowing you switch to REE with minimal hassle or risk. REE has been out for about a year now and is already used by many high-profile websites and organizations, such as New York Times, Shopify and 37signals.

“We switched to enterprise ruby to get the full benefit of the [copy-on-write] memory characteristics and we can absolutely confirm the memory savings of 30% some others have reported. This is many thousand dollars of savings even at today’s hardware prices.”
— Tobias Lütke (Shopify)

And just like Phusion Passenger, Ruby Enterprise Edition is 100% open source.

Announcing the third sponsorship campaign

A lot of exciting things are happening in Ruby land. On the one hand we have Ruby 1.9, which is not only much faster than Ruby 1.8, but also tends to use less memory and has a better threading model. Although the Ruby libraries ecosystem is quickly catching up with 1.9, there are still many libraries which are not yet 1.9-compatible, preventing many people from using Ruby 1.9 in production environments.

On the other hand, people such as Brent Roman, Aman Gupta and Joe Damato have made exciting improvements to the Ruby 1.8 codebase in the areas of performance and memory usage. Some of these improvements bring parts of Ruby 1.8 on par with 1.9, while other improvements potentially affect 1.9 as well. These 1.8 improvements allow us to enjoy the benefits of having a better, faster and less memory hungry Ruby interpreter in production environments, without sacrificing compatibility.

That said, these patches are not small, and merging them with each other, as well as with all the existing Ruby Enterprise Edition patches, is not a trivial job. We have not only been working with these people for a while now to get their patches incorporated into Ruby Enterprise Edition, but we have also sent them financial contributions in order to thank them for their excellent work.

In order to be able to continue to help people who improve Ruby, as well as to cover our own development expenses and business expenses, we are pleased to announce the third Ruby Enterprise Edition sponsorship campaign. It is thanks to the success of the last campaigns, as well as the generosity of the community, that we are able to do this.

Just like the last campaign, this one is public and everyone can participate. This campaign will cover the following work:

Merging Brent Roman’s MBARI patches into Ruby Enterprise Edition.

Brent Roman’s MBARI patch set uses a variety of techniques to significantly reduce Ruby’s memory usage. It also adds a bunch of performance optimizations, useful features and bug fixes.

Ruby’s garbage collector scans the C stack conservatively. This means that any data on the C stack that might look like a pointer pointing to a valid Ruby object will be treated like a real pointer, causing the object to be retained during garbage collection. Because of the way Ruby is written and because of compiler optimizations, there may be a lot of such “pointers” on the stack, even when they’re not really pointers but just garbage data that like look pointers.

Brent has refactored and modified many parts of Ruby in order to reduce the possibility of such “garbage pointers” occurring on the stack. As a result, garbage collection will be much more effective. Many objects that would otherwise not have been freed will be freed thanks to the MBARI patches.

As a side-effect of the reduced memory usage, applications typically run faster as well. Not only because applications are less likely to be swapped out, but also because modern hardware’s performance depends greatly on the amount of memory traffic.

Ruby uses an inefficient, linear time algorithm for extending the stack space when switching context between threads and/or continuations. This is mostly noticeable when you have a lot of threads. Brent replaces this with a constant time algorithm, which is much faster.

It adds the methods __file__ and __line__ to the Method, UnboundMethod and Proc classes. Very useful for inspecting large code bases that make heavy use of metaprogramming.

It fixes some crashing bugs in Ruby’s continuations implementation.

Current status: The MBARI patches partially overlap with our copy-on-write patches, but we have been able to successfully merge the two patch sets together. Merging the result with the other patches, e.g. the RailsBench patches which are also included in REE, is still a work-in-progress, but we expect to be finished very soon.

Joe Damato and Aman Gupta’s SIGVTALRM patch, which is already included in the latest Ruby Enterprise Edition release, fixes a Ruby thread scheduler bug which degrades performance once the last thread in the application (except the main thread) has exited. This is especially important in applications which are mostly single-threaded, but may occasionally spawn a thread. This includes all single-threaded applications that use the ‘timeout’ library, because it is implemented using threads.

This team has recently also created a patch which fixes the performance degradations that occur when –enable-pthread is enabled, as well as a zero-copy context switching patch. In Ruby 1.8, whenever Ruby switches context to another thread, it has to copy over the entire thread stack. This is very expensive, and the deeper your function calls are nested, the slower it becomes. The zero-copy context switching patch removes the need to copy any stack data; instead, it keeps all thread stacks at different areas in memory and simply changes the stack pointer. In extreme situations, this patch can increase threading performance by as much as 10 times!

Phusion Passenger is not really affected by this patch because its request handling core is not multithreaded, at least not at this moment. But Mongrel is heavily multithreaded and will benefit tremendously from this patch.

Current status: We’ve tested this patch, and it turns out that it breaks continuations. We’re working with the authors to solve this issue. Also, parts of this patch overlap with the MBARI patch set. We are currently working on merging them.

Documenting the implications for REE users.

The MBARI patch set adds a few more API calls for tuning the garbage collector, as well as some configure flags for customizing the manner with which memory consumption is reduced. We will document these things.

Campaign goal and conditions

The goal of this campaign is 9000 USD. We have a surplus of 642 USD from the last campaign, and we’ve already factored in this amount.

Once the campaign goal has been reached, we’ll release the work as soon as it has been finished. Highlights:

All sponsors will be given credit on the related REE release announcement on our blog. If the sponsor is an organization then we’ll link to the website, if available.

The money that we receive through this campaign shall be treated like donations.

An invoice is available if both of the following conditions apply:

You are an organization based in the European Union.

You’ve sent 200 USD or more.

If we receive more money than the campaign goal, then the surplus will be used for the next REE sponsorship campaign.

Perhaps breaking the sponsorship campaign up into smaller chunks would be a good idea? It seems like there was a lot of momentum and donations at first and now it has slowed down. I promise you that people care passionately about this project and are incredibly appreciative for all of the work that Phusion has done. Thank you!

“Phusion” and “Phusion Passenger” are registered trademarks of Phusion. “Rails”, “Ruby on Rails” and the Rails logo are registered trademarks of David Heinemeier Hansson. All other trademarks are property of their respective owners.