Windows 上的 Rails 太慢了(rails -v 需要 4 秒)

发布于 2024-10-10 13:16:31 字数 320 浏览 1 评论 0 原文

我在具有 4 GB RAM 的 Intel Core 2 Duo 2,6 Ghz 和 Windows Vista Business SP2 上使用 Rails 版本 3.0.3 和 ruby​​ 版本 1.9.2p136 (2010-12-15),没有运行其他(繁重)应用程序。我已经读到过,Windows 上的 Rails 开发比 Unices 上的开发要慢,而且大多数人这样做是为了不推荐它,但这很愚蠢。

我想不出用 4 秒来显示一个简单的版本号有什么好的理由。而rails生成最多需要10秒才能完成!

我的设置一定有问题(至少我希望如此)。

有人知道如何继续吗?提前致谢!

I'm using rails Version 3.0.3 and ruby Version 1.9.2p136 (2010-12-15) on a Intel Core 2 Duo 2,6 Ghz with 4 GB Ram and Windows Vista Business SP2 with no other (heavy) applications running. I have already read that rails development on Windows is slower than on Unices and most people do there for not recommend it but this is silly.

I can't think of any good reason for using 4 seconds to display a simple Version number. And rails generate needs up to 10 seconds to complete!

Something in my setup must be wrong (at least I hope).

Has someone a good idea how to proceed? Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

旧竹 2024-10-17 13:16:31

有几个关键点共同导致了您注意到的性能缓慢。

  • Ruby IO 性能(在任何版本上)比 Linux 同类产品慢 3 倍。这是因为 Ruby 的 Windows 代码库中有几个未优化的跳转。这需要进一步的分析、调查和优化,直到今天才完成。
  • Ruby 1.9.2 为每个需要的文件生成多个 stat() 调用,这会增加 Ruby 本身的速度。这在 Ruby 1.8.6 或 1.8.7 中不存在。在尚未发布的 Ruby 1.9.3 (trunk) 中也解决了这个问题。
  • 像 Rails 这样的项目需要大约 500 个文件,结合以上几点,使得 Ruby for Windows 成为许多人眼中的蜗牛。

现在,有一些解决方法,有些简单,有些复杂。

  1. 返回到 Ruby 1.8.7 而不是 Ruby 1.9.2。这将为您的应用程序再次带来一定程度的速度。除非您利用 Unicode 支持,否则 1.8.7 可能适合您。
  2. 研究像 Spork 这样的工具,为你的 RSpec/Cucumber 提供场景/分叉
  3. 使用像 ImDisk。将 Ruby 和您的应用程序都移至其中,加载时间将会减少(这也与您的可用 RAM 相关)

希望其中一些选项对您有所帮助。

There are a few key points that combined generate the slow performance you're noticing.

  • Ruby IO performance (on any version) is up to 3 times slower than Linux counterparts. This is because several unoptimized hops in the Windows codebase of Ruby. This requires further analysis, investigation and optimization not done until today.
  • Ruby 1.9.2 produces several stat() calls per file been required, which can increase the slowdown of Ruby itself. This is not present in Ruby 1.8.6 or 1.8.7. This is also solved in Ruby 1.9.3 (trunk) not released yet.
  • Projects like Rails requires around 500 files, which combined with above points make Ruby for Windows the snail lot of folks see.

Now, there are workaround to that, some simple and some complex ones.

  1. Move back to Ruby 1.8.7 instead of Ruby 1.9.2. That will bring again certain level of speed to your application. Unless you're taking advantage of Unicode support, then 1.8.7 could work for you.
  2. Look into tools like Spork to provide scenario/forking for your RSpec/Cucumber
  3. Move your development to RAM, using a RAMDisk like ImDisk. Move both Ruby and your application to it and time of loading will be reduced (this is associated with your available RAM too)

Hope some of these options help you.

清风不识月 2024-10-17 13:16:31

在 Ubuntu 虚拟机中使用 Ruby 比直接在 Windows 中使用速度更快。

一个不错的选择是使用 Vagrant:您在 Windows IDE 上进行开发,文件与 Ubuntu VM“共享”,您运行“vagrant ssh”,然后运行“rails server”,或您想要运行的任何其他命令。还有其他好处:

  • 您不需要安装 RVM,或切换 ruby​​ 版本,只需为每个项目使用一个 VM。 VM 可以很小,比如 500MB 的数据,最多使用 100MB 的 RAM,但是 YMMV
  • 你不需要担心 gem 与 Windows 的兼容性

看看:http://www.vagrantup.com/

It is faster to use Ruby inside an Ubuntu Virtual Machine than using it directly with Windows.

A good option is to use Vagrant: You develop on your Windows IDE, and files are "shared" with the Ubuntu VM, you run "vagrant ssh", then run "rails server", or any other command you'd like to run. There are other benefits as well:

  • Your don't need to install RVM, or switch ruby versions, just use a VM for each project. VMs can be small, like 500MB of data, using up to 100MB of RAM, but YMMV
  • You don't need to worry about gem's compatibility with Windows

Take a look: http://www.vagrantup.com/

瑾夏年华 2024-10-17 13:16:31

为了加速,你可以尝试我的 loader speeder upper(帮助 Rails 在 Windows 中运行得更快): https://github.com/ rdp/faster_require

还可以检查 spork,它可以在 Windows 中运行,jruby 也可以很好地运行。

For a speedup you could try my loader speeder upper (helps rails run faster in Windows): https://github.com/rdp/faster_require

Also checkout spork, which works in Windows, and jruby also works well.

八巷 2024-10-17 13:16:31

你可以尝试使用 ruby​​ 的垃圾收集器来让 ruby​​ 更快,因为默认变量设置也不匹配 Windows 的工作方式

垃圾收集器性能调整

you can try playing with ruby's garbage collecter to make ruby faster, since the defaults variable settings don't match how windows work

also Garbage collector performance tuning

雪化雨蝶 2024-10-17 13:16:31

更有可能的是,它受到了反病毒软件的影响。再加上 Vista 的速度问题可能会影响它。我同意Justice的观点,在虚拟机中运行Linux。

More than likely, it's anti-virus affecting it. That combined with Vista's speed issues are probably affecting it. I agree with Justice, run Linux in a VM.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文