Ahmed Al Hafoudh
Ahmed Al Hafoudh

Reputation: 8429

Slow loading rails environment

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

Upvotes: 2

Views: 1387

Answers (4)

yuvilio
yuvilio

Reputation: 4185

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.

Upvotes: 1

Nevir
Nevir

Reputation: 8101

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.

Upvotes: 1

Ahmed Al Hafoudh
Ahmed Al Hafoudh

Reputation: 8429

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

Upvotes: 1

Nucc
Nucc

Reputation: 1031

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

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

Upvotes: 0

Related Questions