2

Is it OK that loading my rails environment takes 25 seconds?

alhafoudh@xxx:~/Projects/xxx$ time ruby -r./config/environment.rb -e ""
real    0m25.320s
user    0m22.093s
sys     0m1.988s

alhafoudh@xxx:~/Projects/xxx$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

alhafoudh@xxx:~/Projects/xxx$ gem list | grep rails
using rails 3.0.3

I am using also rvm

Ahmed Al Hafoudh
  • 8,281
  • 1
  • 18
  • 34

4 Answers4

1

Update: switching recommendation per comment suggestion

No need to downgrade. One workaround for this is to preload the rails environment with rails-sh. That way only the first rails/rake command is slow and the rest are pretty fast. Wrote a fuller answer to it in this question. I use it currently with ruby 1.9.3p194 with rails 3.2.6.

Community
  • 1
  • 1
yuvilio
  • 3,795
  • 32
  • 35
  • rrails looks fine, rails server starts very fast, but rails console does not work (hangs) and rake spec tells me "uninitialized constant FactoryGirl" There is no documentation for rrails. :( – Ahmed Al Hafoudh Jul 17 '12 at 05:27
  • I [inquired](https://github.com/walf443/rrails/issues/2) from the rrails project about that. Seems rrails wasn't built for console REPLs. He suggested trying the similar [rails-sh](https://github.com/jugyo/rails-sh) – yuvilio Jul 17 '12 at 12:43
  • Yep, after trying it out, it seems rails-sh is a better fit due to it's REPL support. – yuvilio Jul 17 '12 at 15:49
1

I solved it with downgrating my ruby stack to ree-1.8.7 :(

Ahmed Al Hafoudh
  • 8,281
  • 1
  • 18
  • 34
1

Bundler 1.1 helps speed things up, somewhat (20-25% gains).

Otherwise, remove unnecessary gems, if any - and harp on gem authors to lazy-load their library to speed things up.

Nevir
  • 7,951
  • 4
  • 41
  • 50
0

Do you use sqlite or other client-server database engine?

Please run rails console and check whether calling reload! method is also slow...

Nucc
  • 1,031
  • 6
  • 20
  • It does approx. the same times with sqlite, mysql or mysql2 gem. Reload! Is within a second. As I wrote, I tried it with ree-1.8.7 and takes 7-10 seconds. – Ahmed Al Hafoudh Nov 30 '10 at 08:15