Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 script/server - 30 seconds
  • rake test - 45 seconds
  • etc.

Yet, when I pop over to a much slower linux box, it's virtually instantaneous. I've checked everything - no significant CPU processes running, no network issues... and so on.

Heck, I'd be happy with just a verbose output that at least told me where it was breaking down. Any suggestions?

like image 400
aronchick Avatar asked Mar 06 '10 04:03

aronchick


2 Answers

In general Ruby's MRI interpreter is just not optimized for speed on windows. You might also be running it in development mode on windows vs production mode on the other machines. Rails runs much slower in development mode since it reloads all your classes on every request.

1.8.6 is a very old ruby version. Released almost 3 years ago. You should strongly consider upgrading to 1.9 (or at least 1.8.7). Or switching to 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.9 has a completely new interpreter that runs 2.5 times faster (Though it has a tendency to occasionally crash on windows). 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.

One last option would be to try running Rails inside of a VMWare with CentOS or another Linux distribution.

like image 66
Gdeglin Avatar answered Oct 14 '22 07:10

Gdeglin


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.

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.

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. Do it with a scratch version of ruby, though :)

Unfortunately Jruby also isn't known for its exceedingly fast lookups. 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.

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.

-rp

like image 2
rogerdpack Avatar answered Oct 14 '22 08:10

rogerdpack