Configuring Rails for Ruby 2.0 Configuring Rails for Ruby 2.0 linux linux

Configuring Rails for Ruby 2.0


So here's what I had to do after upgrading.

Bundler 1.2.x is not compatible, it raises an error saying to upgrade to >= 1.3, which is not yet release. So if you are using RVM, jump into your global gemset for the 2.0 ruby and upgrade to 1.3.pre version until 1.3.0 is released. Also it seems like there's something up with the rubygems api. My bundle install did not use the new API, instead doing the old 'fetch index' method, which of course takes a little bit longer.

Aside from that, my bundle did install cleanly, and my full set of spec tests completed with all OK. I did some timing tests to see how much the rails load time has improved.

# Using 1.9.3-p327RSpec Time: 24.87sWall Time : 34.40sLoad Time :  9.53s# Using 2.0.0-p0RSpec Time: 22.49s (90.4%)Wall Time : 26.89s (78.2%)Load Time :   4.4s (46.2%)

Obviously the load time for rspec is a little heavier with all of the testing gems, but still over a 50% drop in load time and a 10% drop in test run time is nice.

I did a similar test using rails runner 'puts User.count' which would skip the test bootstrapping.

1.9.3 : 7.27s2.0.0 : 3.36s (46.2%)

Again, nice drop of over 50% :)

Kind of getting off track here... new toys do that I guess, but it seems like the only change I had to make was upgrading to a pre-release bundler.

Here's another test of different iterators

$ rvm 1.9.3-p327,2.0.0-p0 --verbose do ruby test.rbruby-1.9.3-p327: ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]        user     system      total        realfor    0.610000   0.000000   0.610000 (  0.607189)times  0.580000   0.000000   0.580000 (  0.587303)upto   0.590000   0.000000   0.590000 (  0.585730)each   0.590000   0.000000   0.590000 (  0.593494)ruby-2.0.0-p0: ruby 2.0.0p0 (2013-02-24 revision 39474) [i686-linux]        user     system      total        realfor    0.590000   0.000000   0.590000 (  0.582743)times  0.560000   0.000000   0.560000 (  0.565961)upto   0.560000   0.000000   0.560000 (  0.562400)each   0.570000   0.000000   0.570000 (  0.573469)

Marginal, about a 4-5% gain.

More interesting is this, calling Object.new 500 million times

1.9.3 : 129.063s2.0.0 :  97.234s

About a 25% drop in object creation time.


I started a new project with rails 4 and ruby 2.0. This is how I did it.

First, I set RVM to Ruby 2.0.

Then installed bundler 1.3:

$ gem install bundler

Updated these gems and 'bundle install'.

gem 'rails',     :git => 'git://github.com/rails/rails.git'gem 'journey',   :git => 'git://github.com/rails/journey.git'gem 'arel',      :git => 'git://github.com/rails/arel.git'group :assets do  gem 'sass-rails',   :git => 'git://github.com/rails/sass-rails.git'  gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails.git'end