慢速加载轨道环境
加载我的 Rails 环境需要 25 秒,可以吗?
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
我也在用rvm
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我通过将 ruby 堆栈降级到 ree-1.8.7 解决了这个问题:(
I solved it with downgrating my ruby stack to ree-1.8.7 :(
Bundler 1.1 在一定程度上有助于加快速度(提高 20-25%)。
否则,删除不必要的 gem(如果有)——并敦促 gem 作者延迟加载他们的库以加快速度。
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.
更新:根据评论建议切换推荐
无需降级。解决此问题的一种方法是使用 rails-sh 预加载 Rails 环境。这样,只有第一个rails/rake命令很慢,其余的命令都相当快。在这个问题中写了更完整的答案。我目前将它与 ruby 1.9.3p194 和 Rails 3.2.6 一起使用。
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.
您使用 sqlite 或其他客户端-服务器数据库引擎吗?
请运行rails console并检查是否调用reload!方法也慢...
Do you use sqlite or other client-server database engine?
Please run rails console and check whether calling reload! method is also slow...