Slow loading rails environment

只愿长相守 提交于 2019-12-12 17:19:28

问题


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


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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

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



来源:https://stackoverflow.com/questions/4305143/slow-loading-rails-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!