I was excited when I heard that Ruby 1.9.3 was going to halve the startup times for apps that have many, many “require” statements (such as Rails apps), compared to 1.9.2. Unfortunately, after the upgrade, the startup times for my Rails 2.3.14 app are as bad as ever. It takes 50 seconds to get to a prompt after executing “script/console”. In that time, it executes 1499 “require” statements.
My question is, how do I get it to start up faster?
I used the following code snippet at the top of my environment.rb file to log all the require statements:
module Kernel
def require_new(fn)
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} #{fn}"
require_old(fn)
end
alias_method :require_old, :require
alias_method :require, :require_new
end
Imho Ruby 1.9.3 is pretty slow out of the box. What could you do to improve the perfomrance is:
Apply the falcon patch if you’re using p0. Here you’ll find how:
https://gist.github.com/1688857
including the bonus of tuned up environment variables.
Get the freshly baked out Ruby 1.9.3-p125 http://www.ruby-lang.org/en/news/2012/02/16/ruby-1-9-3-p125-is-released/ I checked it, and my first impression is that the performance is greater than p0.
Upgrade Rails, like user shingara mentioned in the comments.