Windows 上的 Rails 太慢了(rails -v 需要 4 秒) [英] Rails on Windows is so slow (rails -v takes 4 seconds)

查看:29
本文介绍了Windows 上的 Rails 太慢了(rails -v 需要 4 秒)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我想不出使用 4 秒来显示简单版本号的任何充分理由.而 rails generate 需要 10 秒才能完成!

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!

推荐答案

有几个关键点结合在一起会导致您注意到性能缓慢.

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

  • 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 成为很多人看到的蜗牛.
  • 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. 回到 Ruby 1.8.7 而不是 Ruby 1.9.2.这将再次为您的应用程序带来一定程度的速度.除非您正在利用 Unicode 支持,否则 1.8.7 可能适合您.
  2. 研究像 Spork 这样的工具来为您的 RSpec/Cucumber 提供场景/分叉
  3. 使用像 ImDisk 这样的 RAMDisk,将您的开发转移到 RAM.将 Ruby 和您的应用程序都移动到它,加载时间将减少(这也与您的可用 RAM 相关联)
  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.

这篇关于Windows 上的 Rails 太慢了(rails -v 需要 4 秒)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆