1

My 3.1.3 rails app takes quite a while to start up, and even running rails console seems to take longer than it reasonably should. For example, with my app it's 50 seconds from rails c to the command prompt. In a test fresh rails app (e.g. from rails new) it's about 5 seconds.

Needless to say, this is really annoying, particularly when trying to run tests, etc.

I've seen the links at https://stackoverflow.com/a/5652640/905282 but they're pretty involved; I was hoping for maybe something that would be at a higher level, like "oh yeah, here's how long each gem is taking up during startup".

Suggestions, or do I just need to dive into the details?

Community
  • 1
  • 1
denishaskin
  • 3,305
  • 3
  • 24
  • 33
  • limit the number of gem you have. And check in your initializer if there are no long task – shingara Feb 15 '12 at 15:21
  • What Ruby version are you using? 1.9.3 [fixes a performance problem in 1.9.2](http://www.rubyinside.com/ruby-1-9-3-faster-loading-times-require-4927.html) with `require`. – tadman Feb 15 '12 at 15:30
  • @tadman - thanks. I am on 1.9.2, will try 1.9.3. – denishaskin Feb 15 '12 at 18:48
  • @shingara - certainly I've considered reducing gems, but I think I need all that I currently have in my Gemfile (about 20). I'm pretty sure I don't have any long-running code in any initializers. – denishaskin Feb 15 '12 at 18:52
  • 1
    Wow. @tadman - huge difference. Moving to 1.9.3, `rails c` now only takes about 10 seconds. I can live with that. – denishaskin Feb 15 '12 at 19:22

1 Answers1

0

Ruby 1.9.3 fixes a performance problem in 1.9.2 when a large number of files have been loaded with require.

That post describes how the performance of including new files is O(N), getting progressively slower the more files are already loaded. Since Rails loads in a lot of files, it is a serious drag on start-up time.

tadman
  • 208,517
  • 23
  • 234
  • 262