aronchick
aronchick

Reputation: 7128

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?

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?

Upvotes: 11

Views: 2418

Answers (4)

Matthias
Matthias

Reputation: 1953

I like taking this approach:

slow rails stack

In my case its

finisher_hook: 22.463 sec

That is the culprit

Upvotes: 1

lambinator
lambinator

Reputation: 11029

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. rake used to take 110+ seconds to execute on 1.9.3-p125, and now takes ~20 seconds on p327. Rails is finally usable on Windows!!

Use RubyInstaller to install..

Upvotes: 1

rogerdpack
rogerdpack

Reputation: 66841

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

Upvotes: 2

Gdeglin
Gdeglin

Reputation: 12618

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.

Upvotes: 7

Related Questions