简体   繁体   English

Rails在ruby 1.9.1上初始化非常慢

[英]Rails initializes extremely slow on ruby 1.9.1

I just got my rails 2.3.8 app running on ruby 1.9.1. 我刚刚在ruby 1.9.1上运行了我的rails 2.3.8 app。 To get into the console, start the webserver, anything that initializes rails, takes 3 - 4 times longer in ruby 1.9 than in ruby 1.8.7. 要进入控制台,启动网络服务器,任何初始化rails的东西,在ruby 1.9中比在ruby 1.8.7中长3-4倍。 I'm using ruby version managers so I can easily switch between ruby 1.9 and ruby 1.8.7. 我正在使用ruby版本管理器,因此我可以轻松地在ruby 1.9和ruby 1.8.7之间切换。 The speed difference happens in both production and development. 速度差异发生在生产和开发中。 I want to use 1.9 because its must faster once everything is running, but the startup time is so bad the app is timing out on Heroku on the first request. 我想使用1.9,因为一旦一切运行它必须更快,但启动时间非常糟糕,应用程序在第一次请求时在Heroku上超时。

Any ideas why ruby 1.9 would be 3 - 4 times slower? 任何想法为什么ruby 1.9会慢3-4倍? I can't figure it out for the life of me. 我无法理解我的生活。

Try using 1.9.2-head instead of 1.9.1. 尝试使用1.9.2-head而不是1.9.1。 It is the recommended version for Rails 3, so you may have better luck. 这是Rails 3的推荐版本 ,所以你可能会有更好的运气。 Rails 2.3.8 starts up very quick on 1.9.2-head from the tests I just ran locally (with Authlogic installed too, btw). Rails 2.3.8在我刚刚在本地运行的测试中以1.9.2开头非常快速启动(也安装了Authlogic,顺便说一句)。

If you are using RVM , type the following: 如果您使用的是RVM ,请键入以下内容:

rvm install 1.9.2-head
rvm use 1.9.2-head

Edit: I tried 1.9.1 p378 with the same app and the start up time took about 13 seconds compared to 5 seconds on 1.9.2-head. 编辑:我尝试使用相同的应用程序1.9.1 p378,启动时间约为13秒,而1.9.2头的启动时间为5秒。 1.9.2-rc1 is due out this month I believe , so that's good news :) 1.9.2-rc1本月即将发布我相信 ,所以这是个好消息:)

It's probably because ruby 1.9 uses gem_prelude (which gives you a large load path) instead of normal rubygems. 这可能是因为ruby 1.9使用gem_prelude(它给你一个很大的加载路径)而不是普通的rubygems。 Checkout the length of $: -- that gets searched once for each require, causing extra time 检查$: - 的长度,每次需要搜索一次,从而导致额外的时间

If you want it the old way, (upgrade to the latest version of rubygems and) run ruby --disable-gems 如果你想要它的旧方式,(升级到最新版本的rubygems并运行ruby --disable-gems)

If you are on windows, take a look into my faster_require gem. 如果您在Windows上,请查看我的faster_require gem。

http://github.com/rdp/faster_require http://github.com/rdp/faster_require

Though I suppose, now that you mention it, it might help in 1.9 Linux. 虽然我想,现在你提到它,它可能有助于1.9 Linux。 Maybe. 也许。

GL! GL! -rp -rp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM