Rubinus is a ruby VM written in C with true parallelism support, and a cool design that attempts to write as much of the interpreter as possible in ruby itself.
It’s been developed for a few years now, with financial supported by Engine Yard and is stating to mature. Heroku have included it as pre-installed ruby option, so it’s now quite easy to use.
Here’s how I set it up in dev & on heroku:
# in bash # update RVM rvm get head # install rubinius rvm install rbx-2.0.0.rc1 # list versions rvm list # set as default (I found for the "rails" command to work correctly it needed to be default) rvm --default use rbx-2.0.0.rc1 # export RBXOPT in your bash_login to always select ruby 1.9.3 echo "export RBXOPT=-X19" >> ~/.bash_login # reload bash_login . ~/.bash_login # check ruby version ruby -v #=> rubinius 2.0.0.rc1 (1.9.3 e9973fcd yyyy-mm-dd JI) [x86_64-apple-darwin12.3.0]
Make sure it says rubinus 2.0.0 and “1.9.3”, and you’re set. You’ll need to do a
bundle install to install the gems for rubinius. Now
rails s and
rails c should *just work*.
NB. you may get the error message
Unknown ruby interpreter version: '1.9.3,engine:rbx,engine_version:2.0.0.rc1'.. This result from RVM trying to discern your ruby preference from your gem file, and failing. This is a known issue. You can safely ignore it, but you’ll need to set your default ruby version manually (as detailed above).
The next step is getting the same environment in Heroku. It’s surprisingly easy.
# Gemfile ruby "1.9.3", :engine => "rbx", :engine_version => "2.0.0.rc1"
Commit & deploy as usual.
Want to switch back to the old MRI ruby? Simply revert your Gemfile & reset your rvm default:
# Gemfile ruby "1.9.3"
# in bash rvm list rvm --default use ruby-1.9.3-p125
If everything is going well with Rubinus, then it’s time to switch to a server like Puma which can take full advantage of the the OS-threads. Also, remember to enable multi-thread support on Rails, or use Rails 4 (where it’s on by default). You can ready my steps on using Puma (but ignore the bit about setting the thread count to 1 if you’re running with Rubinus!), or some further reading.