Aug
10
How much faster is Ruby on Linux?
Filed Under Ruby, Ruby Benchmark Suite | 13 Comments
In a previous article I compared the performance of Ruby on Windows, built through Microsoft Visual C++ and GCC. The numbers for the MinGW version were very impressive. So the question now becomes, how does its performance compare to that of Ruby on Linux? To quote one person (Alex) who commented on the aforementioned post:
With the new mingw32 substantial speed improvements, think it makes sense now to also test at least the baseline (MRI) on Mac/Linux on the same battery of tests, so we Windows folks could get a better idea of how far behind are we yet and what the different Windows interpreters speed target shall be.
Any sort of performance improvement for something that is notoriously slow on Windows is more than welcome, but would this be enough to fill the gap between Ruby’s performance on Windows and on Linux? How much faster is Ruby on Linux? Let’s find out.
Setup
- As a reminder, the operating systems used were Windows XP SP3 32bit and Ubuntu 9.04 32 bit.
- The Ruby implementations tested were ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32], ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32], Ruby 1.8.6 (built from source on Linux) and Ruby 1.9.1 (built from source on Linux as well). The same identical versions of Ruby were used for both operating systems. I’m aware that these are not the latest available versions for Linux, but we are trying to compare apples to apples.
- I used the Ruby Benchmark Suite; the times reported are the best out of five runs, with a timeout of 300 seconds per each iteration.
Benchmark results
The following table/image compares the performance of Ruby 1.8.6 on Windows and Linux. A light green background indicates which of the two was faster. The total times exclude tests that raised an error or were not available (N/A) for any of the four implementations, but includes timeouts (they are counted as 300 seconds to provide a lower bound). The ratio column indicates how many times faster Ruby on Linux was:

The second table/image below compares Ruby 1.9.1 on Windows and on Linux, using the same criteria as above.

Note: The totals shown are different from the ones seen in other posts since the subset of benchmarks included in the totals is different.
Conclusion
According to the geometric mean of the ratios for these tests, it appears that on average Ruby 1.8.6 on Linux is about twice as fast as Ruby 1.8.6 on Windows. Conversely, Ruby 1.9.1 on Linux is about 70% faster than the Windows version.
The Windows implementations use GCC 3.4.5 (a four year old compiler) at the moment, while I built the implementations on Ubuntu with GCC 4.3.3 (which is available by default). This helps, at least in part, to justify the performance gap. Luis Lavena, leader of the Windows port, confirmed to me that a switch to GCC 4.4.x is planned for the future. This should significantly increase performance on Windows yet again, and bump Ruby’s speed on Windows a bit closer to the speed that’s obtainable on Linux.
For the time being, switching to Ruby 1.9.1 on Windows will give you a performance that is better than what’s obtained by those who are still using Ruby 1.8.x on Linux. If it’s possible, switch.
Aug
4
A faster Ruby on Windows is possible (benchmarks for 4 implementations inside)
Filed Under .NET, Ruby, Ruby Benchmark Suite | 22 Comments
In yesterday’s post I compared IronRuby 0.9, Ruby 1.8.6 (from the One-Click Installer) and Ruby 1.9.1 (downloaded from the official site) against one another. IronRuby did great, but the discussion in the comment section quickly veered towards what version of the One-Click Ruby Installer should have been used.
I justified my choice of using the “old” One-Click Installer, by the fact that I wasn’t aware of official releases of the new installer. As well as that the old One-Click Installer is the most widely downloaded version. Very few people are familiar with the upcoming version of the project. This point is about to change.
Luis Lavena took over the One-Click Installer project and has been working on the next version (RubyInstaller from now on), the aim of which is to replace the One-Click Installer by building Ruby 1.8 and 1.9 with MinGW and GCC. In theory, this brings performance gains on Windows to the table, and gets rid of having to use Visual C++ 6 (a “ten year old compiler”) to build Ruby and other native gems. The project also strives to be lighter by bundling fewer (unnecessary) gems for Windows users.
There’s no doubt that in the long run, this new project will become the de facto standard for Windows, but the questions on everyone’s mind are, should I bother with it now? How much of a performance boost are we talking about here? 10%? 20%? Let’s find out.
In this follow up article I’m going to compare the performance of Ruby 1.8.6 from the One-Click Installer (mswin32), Ruby 1.8.6 from RubyInstaller (mingw32), Ruby 1.9 (mswin32) downloaded from the Ruby-Lang.com site, and Ruby 1.9 from the RubyInstaller project (mingw32) against one another. I’ll copy and paste part of the setup and disclaimer from yesterday’s post, for those who haven’t read it. Feel free to skip this part if you wish.
Setup
- The benchmarks were run within a virtual machine with 2 GB of DDR3 RAM and a 2.66 GHz Intel Core 2 Duo processor. The operating system adopted was Windows XP SP3 (32 bit) with the .NET Framework 3.5 SP1 installed.
- Here I employed a large subset of the current Ruby Benchmark Suite project. The source code for all of the benchmarks is available within the repository.
- The best time out of five runs is reported for each benchmark. When the results report a Timeout, it means that more than 300 seconds were required for a single iteration and was therefore interrupted. Conversely, N/A means that a test that was compatible for the given implementation was not available or the setup on my machine was lacking the required libraries to execute it (1 test affected).
Disclaimer
- An attempt has been made to improve the quality of the tests. Some of them may be more representative of realistic workloads, but most of them remain micro-benchmarks. They are indicative of how these implementations compare, but cannot be viewed as a guarantee of how they will actually affect your own programs.
- There are lies, damned lies, and statistics.
Benchmark results
The table/image below shows the times for each benchmark, for Ruby 1.8.6 (mswin32), Ruby 1.8.6 (mingw32), Ruby 1.9.1 (mswin32), and Ruby 1.9.1 (mingw32). In the table I used (RI) as shorthand for RubyInstaller to indicate mingw32 versions.

Red values are errors, timeouts and inapplicable tests. Green, bold values indicate better times than what Ruby 1.8.6 (mswin32) delivered. A pale yellow background indicates the best time for a given benchmark. Total time is the run-time for the subset of benchmarks that were successfully executed by all four implementations. Timeouts have been included this time around. Each timeout has been counted as an additional 300 seconds.
The total runtime (including timeouts) is summarized in the chart below:

Conclusion
Wow! Ruby 1.8.6 (mingw32) improves from 3% to 664% (depending on the test), over the current One-Click Installer. The geometric mean of the ratios (read “on average”) tells us that it was about 283% faster. The Ruby 1.9.1 version provided by the RubyInstaller was slower than the mswin32 version in a couple of tests, but faster everywhere else. How much faster? Up to 342% faster, with an average (again calculated through the geometric mean of the ratios) of a 77% increase in speed.
These finds prompt me to ask, what are we waiting for? You know how unresponsive Ruby is on Windows, and how tests take forever to execute? These mingw32-based releases may very well solve this. And incidentally the bar has been raised for IronRuby as well. I formally invite the Ruby on Windows community to embrace these two projects.
Aug
3
Comparing the performance of IronRuby, Ruby 1.8 and Ruby 1.9 on Windows
Filed Under .NET, Ruby, Ruby Benchmark Suite | 19 Comments
In my latest article I discussed the importance of JRuby as a means of introducing Ruby to the Enterprise world. Most of the companies that belong to this ecosystem are Java based, but we cannot forget that a sizable portion of them are Microsoft-centric. Within these companies, Ruby will be far more welcome if a .NET implementation is available. The answer to this need is sufficiently fulfilled by IronRuby (version 0.9 was just released).
IronRuby has been progressing fast lately. First came support for Rails and then, with this release, a great deal of effort has been placed on improving performance. In the past, IronRuby was all but fine-tuned. In fact, it was several times slower than Ruby MRI, as the team worked on improving compatibility with Ruby 1.8 and mostly ignored performance.
In this article I’m going to provide some performance results for IronRuby 0.9 on Windows, which I’m sure will interest readers of this blog as well as of my book. Before revealing all the details, let’s start with the setup and a disclaimer. Please read through it carefully, because the old, trite comments about how “micro-benchmarks are useless” won’t be published. We’ve already been there, folks. Thank you all for your understanding.
Setup
- The benchmarks were run within a virtual machine with 2 GB of DDR3 RAM and a 2.66 GHz Intel Core 2 Duo processor. The operating system adopted was Windows XP SP3 (32 bit) with the .NET Framework 3.5 SP1 installed.
- Here I employed a large subset of the current Ruby Benchmark Suite project. The source code for all of the benchmarks is available within the repository.
- The best time out of five runs is reported for each benchmark. When the results report a Timeout, it means that more than 300 seconds were required for a single iteration and was therefore interrupted. Conversely, N/A means that a test that was compatible for the given implementation was not available (2 tests) or the setup on my machine was lacking the required libraries to execute it (1 test).
- I realize that there is a MinGW One-Click Installer effort that may improve the performance of Ruby on Windows. Here however, I used the regular One-Click Installer as it is the most common one (it’s been downloaded almost 3.5 million times so far). For Ruby 1.9 I used the binary provided by the download page on the official Ruby site.
Disclaimer
- An attempt has been made to improve the quality of the tests. Some of them may be more representative of realistic workloads, but most of them remain micro-benchmarks. They are indicative of how IronRuby compares to MRI (Ruby 1.8) and KRI (Ruby 1.9) performance-wise, but cannot be viewed as a guarantee of how this will actually affect your own programs.
- I didn’t calculate a RubySpec completeness score for IronRuby. That said, IronRuby 0.9 should be a fairly complete implementation of Ruby 1.8.
- There are lies, damned lies, and statistics.
Benchmark results
The table below shows the times for each benchmark, for IronRuby 0.9, Ruby 1.8.6 (2008-08-11 patchlevel 287) and Ruby 1.9.1p0 (2009-01-30 revision 21907):
| Benchmark File | # | Ruby 1.8.6 | IronRuby | Ruby 1.9.1 |
| macro-benchmarks/bm_gzip.rb | 100 | Timeout | IOError | N/A |
| macro-benchmarks/bm_hilbert_matrix.rb | 20 | 1.891 | 0.453 | 0.125 |
| macro-benchmarks/bm_hilbert_matrix.rb | 30 | 7.422 | 1.719 | 0.656 |
| macro-benchmarks/bm_hilbert_matrix.rb | 40 | 21.500 | 4.625 | 2.266 |
| macro-benchmarks/bm_hilbert_matrix.rb | 50 | 56.765 | 10.031 | 5.109 |
| macro-benchmarks/bm_hilbert_matrix.rb | 60 | 111.859 | 18.781 | 11.297 |
| macro-benchmarks/bm_norvig_spelling.rb | 50 | Timeout | 41.313 | 31.453 |
| macro-benchmarks/bm_sudoku.rb | 1 | 43.734 | Timeout | 6.313 |
| micro-benchmarks/bm_app_factorial.rb | 5000 | 1.328 | 0.063 | 0.266 |
| micro-benchmarks/bm_app_fib.rb | 30 | 6.156 | 0.594 | 0.813 |
| micro-benchmarks/bm_app_fib.rb | 35 | 74.125 | 6.922 | 9.344 |
| micro-benchmarks/bm_app_mandelbrot.rb | 1 | 11.953 | 6.922 | 0.641 |
| micro-benchmarks/bm_app_pentomino.rb | 1 | Timeout | 59.938 | 75.859 |
| micro-benchmarks/bm_app_strconcat.rb | 1.5M | 30.469 | 2.141 | 4.813 |
| micro-benchmarks/bm_app_tak.rb | 7 | 5.516 | 0.531 | 0.578 |
| micro-benchmarks/bm_app_tak.rb | 8 | 15.609 | 1.484 | 1.703 |
| micro-benchmarks/bm_app_tak.rb | 9 | 45.843 | 3.953 | 4.531 |
| micro-benchmarks/bm_app_tarai.rb | 3 | 19.985 | 1.844 | 2.156 |
| micro-benchmarks/bm_app_tarai.rb | 4 | 19.796 | 2.219 | 2.656 |
| micro-benchmarks/bm_app_tarai.rb | 5 | 24.235 | 2.688 | 3.063 |
| micro-benchmarks/bm_binary_trees.rb | 1 | Timeout | 53.078 | 37.375 |
| micro-benchmarks/bm_count_multithreaded.rb | 16 | 0.297 | 0.266 | 0.328 |
| micro-benchmarks/bm_count_shared_thread.rb | 16 | 0.250 | 0.188 | 0.203 |
| micro-benchmarks/bm_fannkuch.rb | 8 | 3.625 | 0.344 | 0.563 |
| micro-benchmarks/bm_fannkuch.rb | 10 | Timeout | 40.750 | 65.438 |
| micro-benchmarks/bm_fasta.rb | 1M | 192.937 | 23.703 | 35.234 |
| micro-benchmarks/bm_fractal.rb | 5 | 43.172 | 4.672 | 5.781 |
| micro-benchmarks/bm_gc_array.rb | 1 | 228.672 | 32.031 | 59.828 |
| micro-benchmarks/bm_gc_mb.rb | 500K | 8.109 | 1.109 | 0.469 |
| micro-benchmarks/bm_gc_mb.rb | 1M | 16.172 | 2.391 | 1.016 |
| micro-benchmarks/bm_gc_mb.rb | 3M | 44.953 | 6.906 | 2.938 |
| micro-benchmarks/bm_gc_string.rb | 1 | 47.937 | 25.250 | 11.938 |
| micro-benchmarks/bm_knucleotide.rb | 1 | 9.625 | 2.906 | 2.016 |
| micro-benchmarks/bm_lucas_lehmer.rb | 9689 | 122.672 | 18.125 | 36.250 |
| micro-benchmarks/bm_lucas_lehmer.rb | 9941 | 156.750 | 19.625 | 39.391 |
| micro-benchmarks/bm_lucas_lehmer.rb | 11213 | 179.915 | 28.844 | 61.063 |
| micro-benchmarks/bm_lucas_lehmer.rb | 19937 | Timeout | 159.078 | Timeout |
| micro-benchmarks/bm_mandelbrot.rb | 1 | Timeout | 65.781 | 81.766 |
| micro-benchmarks/bm_mbari_bogus1.rb | 1 | 0.031 | 40.406 | 8.781 |
| micro-benchmarks/bm_mbari_bogus2.rb | 1 | 0.156 | Timeout | N/A |
| micro-benchmarks/bm_mergesort_hongli.rb | 3000 | 25.282 | 3.531 | 6.031 |
| micro-benchmarks/bm_mergesort.rb | 1 | 24.735 | 3.906 | 3.219 |
| micro-benchmarks/bm_meteor_contest.rb | 1 | 147.704 | 19.713 | 19.781 |
| micro-benchmarks/bm_monte_carlo_pi.rb | 10M | 79.406 | 5.109 | 20.672 |
| micro-benchmarks/bm_nbody.rb | 100K | 37.625 | 8.281 | 10.938 |
| micro-benchmarks/bm_nsieve_bits.rb | 8 | 69.656 | 33.156 | 6.531 |
| micro-benchmarks/bm_nsieve.rb | 9 | 58.344 | 5.453 | N/A |
| micro-benchmarks/bm_partial_sums.rb | 2.5M | 93.391 | 10.797 | 26.422 |
| micro-benchmarks/bm_pathname.rb | 100 | Timeout | Timeout | Timeout |
| micro-benchmarks/bm_primes.rb | 3000 | 21.359 | 9.594 | 0.031 |
| micro-benchmarks/bm_primes.rb | 30K | Timeout | Timeout | 0.469 |
| micro-benchmarks/bm_primes.rb | 300K | Timeout | Timeout | 5.281 |
| micro-benchmarks/bm_primes.rb | 3M | Timeout | Timeout | 100.406 |
| micro-benchmarks/bm_quicksort.rb | 1 | 51.046 | 11.594 | 8.703 |
| micro-benchmarks/bm_regex_dna.rb | 20 | 181.172 | 21.188 | 11.938 |
| micro-benchmarks/bm_reverse_compliment.rb | 1 | 61.875 | 48.469 | 138.047 |
| micro-benchmarks/bm_so_ackermann.rb | 7 | 2.234 | 0.563 | 0.484 |
| micro-benchmarks/bm_so_ackermann.rb | 9 | 50.000 | 14.938 | 9.281 |
| micro-benchmarks/bm_so_array.rb | 9000 | 26.328 | 8.984 | 10.781 |
| micro-benchmarks/bm_so_count_words.rb | 100 | Timeout | 60.688 | 42.250 |
| micro-benchmarks/bm_so_exception.rb | 500K | 78.125 | Timeout | 32.672 |
| micro-benchmarks/bm_so_lists_small.rb | 1000 | 13.906 | 4.250 | 3.172 |
| micro-benchmarks/bm_so_lists.rb | 1000 | 64.531 | 22.266 | 16.797 |
| micro-benchmarks/bm_so_matrix.rb | 60 | 8.312 | 2.781 | 2.125 |
| micro-benchmarks/bm_so_object.rb | 500K | 16.375 | 5.313 | 1.672 |
| micro-benchmarks/bm_so_object.rb | 1M | 29.312 | 10.500 | 2.844 |
| micro-benchmarks/bm_so_object.rb | 1.5M | 43.312 | 16.000 | 4.281 |
| micro-benchmarks/bm_so_sieve.rb | 4000 | 241.922 | 37.859 | 35.688 |
| micro-benchmarks/bm_socket_transfer_1mb.rb | 10K | 13.266 | SocketError | 3.359 |
| micro-benchmarks/bm_spectral_norm.rb | 100 | 5.110 | 0.922 | 0.719 |
| micro-benchmarks/bm_sum_file.rb | 100 | Timeout | 20.406 | 23.797 |
| micro-benchmarks/bm_word_anagrams.rb | 1 | 70.828 | 30.188 | 8.125 |
| TOTAL TIME | - | 2933.334 | 607.088 | 664.094 |
Red values are errors, timeouts, inapplicable tests and times that were worse than Ruby 1.8.6. Green, bold values are better times than what Ruby 1.8.6 delivered. A pale yellow background indicates the best time for a given benchmark. Total time is the runtime for the subset of benchmarks that were successfully executed by all three implementations (whose cardinality is 54).
The total runtime is summarized by the chart below:

And let’s compare each of the “macro-benchmarks” on an individual basis:

Conclusions
IronRuby went from being much slower than Ruby MRI to considerably faster across nearly all the tests. That’s major progress for sure, and the team behind the project deserves mad props for it.
One final warning before we get too excited here. IronRuby is not faster than Ruby 1.9.1 at this stage. Don’t let that first chart mislead you. While it’s faster in certain tests, it’s also slower is many others. Currently, it’s situated between Ruby 1.8.6 and Ruby 1.9.1, but much closer to the latter. The reason why this chart is misleading is that it doesn’t take into account any tests that timed out, and several of such timeouts were caused by IronRuby (more than those caused by Ruby 1.9.1). If you were to add, say, 300 seconds to the total, for each timeout for the two implementations, you’d quickly see that Ruby 1.9.1 still has the edge. The second chart that compares macro-benchmarks does a better job at realistically showing how IronRuby sits between Ruby 1.8.6 and Ruby 1.9.1 from a performance standpoint. If you were to plot every single benchmark on a chart, you’d find a similar outcomes for a large percentage of the tests.
Whether it’s faster than Ruby 1.9 or not, now that good performances are staring to show up, it’s easier to see IronRuby delivering on it’s goal of becoming the main implementation choice for those who both develop and deploy on Windows. This, paired with the .NET and possible Visual Studio integration, the great tools available to .NET developers, and the ability to execute Ruby code in the browser client-side thanks to projects like Silverlight/Moonlight and Gestalt, make the project all the more interesting.
What are your thoughts on IronRuby, and how will this dramatic performance gain affect your projects?





















