Our team at work is currently in the beginning stages of a new project, that we started on Ruby 1.9.2 and Rails 3.1. Most of our previous work was all Ruby 1.8.7 (Ruby Enterprise Edition) and Rails 2, though I have worked on a couple of REE 1.8.7 + Rails 3.0 apps.
I’ve also jumped with both feet (and not in the fun, fancy, parkour sense, in the 37-year old, flat arched, off a perfectly good one-story building onto concrete sense) into testing, and tenuously into TDD – and I think my first comment was “man, these tests are hella slow.”. Only it’s not the tests that are slow (yet) – it’s rake. That was my second comment – “what the hell is wrong with rake?” My co-workers even looked at me a little funny when I brought it up.
As we were getting started last month, Rails 3.1 was still in RC status – and I would spend time browsing the Rails issues keeping track of the progress – and I remember reading this issue about Rails 3.1 boot performance – and reading the comment about the “require issue”. That led me via Google to this stack overflow post and this rubyonrails core post – which I basically chalked up “core problem, it’ll be fixed one day”
Well that “one day” is now, because I can’t take it anymore.
This is the rails console startup in REE-1.8.7/Rails 2.3.14
This is the rails console startup in 1.9.2/Rails 3.1
Just a flat out “rake –tasks” takes over 9 seconds in 1.9.2/Rails 3.1!
So thankfully, google, the internet, and other irritated developers to the rescue. Thanks to this blog post from Xavier Shay (via: Peter Cooper at Ruby Inside, that I missed in my feeds the first time because “1.9.3” is not on my radar) – and especially this gist from Todd Fisher – and I have a glimmer of relief.
The quick instructions for the above:
- grab the patch from the gist
- patch ruby
- copy my gemset(s) over
- change my .rvmrc for the project…and voila!
rake –tasks is now 6 seconds instead of 9, and test initialization is correspondingly faster as well.
It’s not REE 1.8.7/Rails 2 – but I’ll take any speedup I can get.