views:

203

answers:

2

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?

+4  A: 

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.

Gdeglin
In addition, it's possible that the OP is using the One-Click Installer, which is now quite old and superseded by RubyInstaller. The RubyInstaller for 1.8.7 is probably the minimum that should used at this point.
Stuart Ellis
I believe I _am_ using the 1-click installer (they should really remove that from the ruby-lang.org). I'll try moving up to 1.9.1 even though that's not our production environment. Is JRuby significantly faster?
aronchick
I think they plan on removing it once rubyinstaller "comes out of RC"
rogerdpack
+1  A: 

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.

-rp

rogerdpack
Thanks! What about 1.8.7?
aronchick
BTW, does this work help at all? http://jira.codehaus.org/browse/JRUBY-4073
aronchick
I haven't tried jruby with rails much on doze--my hunch is it would be about as slow as MRI.My answers are the same for 1.8.7 as for 1.8.6 (and 1.9.x for that matter, is typically worse) though it appears that 1.9.2 is going to be a bit faster in this regard than 1.9.1 [1]).[1] http://redmine.ruby-lang.org/issues/show/2723
rogerdpack