简体   繁体   English

Windows中的耙测试非常慢

[英]Rake Test Very Slow in Windows

Why is Ruby, and Ruby on Rails (1.8.6 One Click Installer, local database) so ruddy slow on Windows? 为什么Ruby和Ruby on Rails(1.8.6 One Click Installer,本地数据库)在Windows上如此邋slow?

  • ruby script/server - 30 seconds ruby脚本/服务器 - 30秒
  • rake test - 45 seconds 耙子测试 - 45秒
  • etc. 等等

Yet, when I pop over to a much slower linux box, it's virtually instantaneous. 然而,当我弹出一个慢得多的linux盒子时,它几乎是瞬间完成的。 I've checked everything - no significant CPU processes running, no network issues... and so on. 我已经检查了所有内容 - 没有重要的CPU进程在运行,没有网络问题......等等。

Heck, I'd be happy with just a verbose output that at least told me where it was breaking down. 哎呀,我很高兴只有一个冗长的输出,至少告诉我它在哪里崩溃。 Any suggestions? 有什么建议?

In general Ruby's MRI interpreter is just not optimized for speed on windows. 一般来说,Ruby的MRI解释器并没有针对窗口速度进行优化。 You might also be running it in development mode on windows vs production mode on the other machines. 您可能还在其他计算机上的Windows vs生产模式下以开发模式运行它。 Rails runs much slower in development mode since it reloads all your classes on every request. Rails在开发模式下运行得慢得多,因为它会在每个请求上重新加载所有类。

1.8.6 is a very old ruby version. 1.8.6是一个非常古老的红宝石版本。 Released almost 3 years ago. 大约3年前发布。 You should strongly consider upgrading to 1.9 (or at least 1.8.7). 您应该强烈考虑升级到1.9(或至少1.8.7)。 Or switching to JRuby. 或者切换到JRuby。 All of these options will likely lead to a significant performance improvement. 所有这些选项都可能会带来显着的性能提升。

1.8.7 should be fully compatible with 1.8.6. 1.8.7应与1.8.6完全兼容。 1.9 has a completely new interpreter that runs 2.5 times faster (Though it has a tendency to occasionally crash on windows). 1.9有一个全新的解释器,运行速度提高了2.5倍(尽管它偶尔会在窗口上崩溃)。 JRuby may be the ideal solution for you since you can run it in either compatibility for 1.8 or 1.9 and it is very stable, but it does not support gems with C extensions and requires a different database adapter. JRuby可能是您理想的解决方案,因为您可以在1.8或1.9的兼容性中运行它并且它非常稳定,但它不支持具有C扩展的gem并且需要不同的数据库适配器。

One last option would be to try running Rails inside of a VMWare with CentOS or another Linux distribution. 最后一个选择是尝试使用CentOS或其他Linux发行版在VMWare中运行Rails。

The reason is that file stat's in windows are dreadfully slow, and, since Ruby is written on Linux (and optimized for Linux), there hasn't been much work to make it faster. 原因是Windows中的文件统计速度非常慢,并且,由于Ruby是在Linux上编写的(并且针对Linux进行了优化),因此没有太多工作可以使其更快。

Using the rubyinstaller.org (1.8.6 or 1.9.x) can make it faster--I'd recommend 1.8.6 since 1.9 has some slowdowns of its own. 使用rubyinstaller.org(1.8.6或1.9.x)可以使它更快 - 我推荐1.8.6,因为1.9自身有一些减速。

If you're looking to get really aggressive, you can try my faster_gem_script gem, which tries to cache the heck out of require based look ups and thus speed things up. 如果你想要变得非常积极,你可以尝试我的faster_gem_script gem,它试图缓存基于需求的查找,从而加快速度。 Do it with a scratch version of ruby, though :) 使用划痕版本的红宝石做,但:)

Unfortunately Jruby also isn't known for its exceedingly fast lookups. 不幸的是,Jruby也因其极快的查找而闻名。 Hopefully this situation will change someday. 希望有一天这种情况会改变。 Until then my faster_gem_script and faster_require are the only way I know of to try to get some speedup. 在那之前,我的fast_gem_script和faster_require是我知道尝试获得一些加速的唯一方法。

For a speedup you could try my loader speeder upper (helps rails run faster in doze): https://github.com/rdp/faster_require Also checkout spork, which works in doze, and jruby also works well. 对于加速,你可以尝试我的装载机调速器上部(帮助导轨在打瞌睡中跑得更快): https//github.com/rdp/faster_require也是checkout spork,它在打瞌睡中起作用,jruby也很好用。

-rp -rp

UPDATE: Thanks (in part) to some really great work on Fenix by Luis Lavena, Ruby 1.9.3-p327 is much, much faster on Windows. 更新:感谢(部分)对Luis Lavena的一些非常出色的Fenix工作,Ruby 1.9.3-p327在Windows上快得多。 rake used to take 110+ seconds to execute on 1.9.3-p125, and now takes ~20 seconds on p327. rake曾经花了110多秒在1.9.3-p125上执行,现在在p327上需要大约20秒。 Rails is finally usable on Windows!! Rails最终可以在Windows上使用!!

Use RubyInstaller to install.. 使用RubyInstaller安装..

I like taking this approach: 我喜欢这种方法:

slow rails stack 慢铁栈

In my case its 在我的情况下它

finisher_hook: 22.463 sec

That is the culprit 那是罪魁祸首

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

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