Ruby 1.8/1.9 performance on Gentoo Linux and FreeBSD
I’ve used the Ruby Benchmark Suite to do a few benchmarks on MRI (Ruby 1.8) and YARV (Ruby 1.9), both on Gentoo Linux and FreeBSD.
First, the results
The results for version 1.8 are as follows:

The FreeBSD situation improved a bit on version 1.9. The results were:

Benchmark details
Ruby 1.8 and 1.9, as you have seen, were considered in this benchmark. The respective versions and patchlevels are:
- Ruby 1.8.7 (patchlevel 249)
- Ruby 1.9.1 (patchlevel 376)
Both versions were compiled from source using Portage and Ports for Gentoo Linux and FreeBSD, respectively. The gcc flags I used upon compilation were:
-O2 -march=nocona -pipe
The packages’ configurations in FreeBSD matched the one’s used in Gentoo’s Portage (USE flags). For the curious ones, eix dev-lang/ruby yields:
[I] dev-lang/ruby
Available versions:
(1.8) 1.8.6_p388 1.8.7_p249
(1.9) {M}(~)1.9.1_p243 {M}(-*)1.9.1_p376[1]
{berkdb debug doc emacs examples gdbm ipv6 rubytests socks5 ssl threads tk xemacs}
Installed versions: 1.8.7_p249(1.8)(10:55:54 02/17/10)(berkdb gdbm ipv6 ssl threads -debug -doc
-emacs -examples -rubytests -socks5 -tk -xemacs)
1.9.1_p376(1.9)[?](15:57:28 02/19/10)(berkdb gdbm ipv6 ssl -debug -doc -emacs
-examples -rubytests -socks5 -tk -xemacs)
Homepage: http://www.ruby-lang.org/
Description: An object-oriented scripting language
[1] /usr/local/portage
The benchmark settings used were the default ones. Every benchmark ran a total 5 times (only the best being considered) and each test had a 300 second timeout.
The totals’ calculations excluded the tests that resulted in errors, so that only successful tests in both operating systems were taken into account.
Conclusions
Ruby runs faster on Gentoo Linux than in FreeBSD. For version 1.8.7, the difference is 29.34% and version 1.9.1 represents a 22.21% difference.
Ruby 1.9.1 is also significantly faster than Ruby 1.8.7 (89.59% in Gentoo Linux and 100% faster in FreeBSD). This also means that upgrading your Rails applications to Ruby 1.9 will likely boost your application’s performance significantly.
Antonio Cangiano did a similar benchmark a few months ago where he compared the performance of Ruby’s MRI and YARV under Linux and Windows. By his results, we can see that the Linux implementation also outperforms the Windows’ one but by a much larger margin (near 100% for Ruby 1.8 and near 73% for Ruby 1.9).
Ruby seems to like the Linux operating system. It runs significantly faster on this platform than in Windows and BSD. If you need performance and your application depends on Ruby, Linux should probably be your server’s operating system.