After
this post , reporting a stunning increase in the performance of JRuby in version 1.7 when working on OpenJDK 7u2 3 times compared to previous releases.
Recalling the relative stagnation and gluttony of JRuby in 2009, and just
such statistics from Programming languages shootout, I decided to give JRuby another chance.
The comparison does not claim either the accuracy of the measurements or the comprehensiveness of the tests, but is only intended to find out whether JRuby YARV has caught up with performance or not. At the start, attention,
Installation
sudo pacman -Syu # update
sudo sudo pacman -S jdk7-openjdk apache-ant # set jre7-openjdk-7.b147_2.0-4 and apache ant
rvm install jruby-head ruby-1.9.3p0 # install JRuby (75MB OMG!) and YARV 1.9.3
rvm use jruby-head
ruby --version #jruby 1.7.0.dev (ruby-1.8.7-p352) (2011-12-22 3d34ca5) (OpenJDK Client VM 1.7.0_147-icedtea) [linux-i386-java]
Test time
Synthetic tests are of little interest, so we will run what Ruby usually does:
- templating;
- input Output;
-
calculation of Fibonacci numbers ;
- routing.
')
We will run the web application, and measure its performance. We will need
httperfsudo sudo pacman -S httperf
For each version of ruby we will run:
gem install sinatra slim
Simple application:
#! / usr / bin / env ruby
require 'rubygems'
require 'sinatra'
require 'slim'
get '/' do
slim: index
end
get '/ 2' do
slim: tyndex
end
__END__
@@ layout
html
== yield
@@ index
div.title Hello world !!!
@@ tyndex
div.title Bye world !!!!!
It may be a big mistake to run it on WEBrick, but we are not comparing the web server, but the implementation of the language itself.
Run:
ruby config.ru
time httperf --hog --server localhost --port 4567 --num-conn 500 --ra 500
results
Juby
Request rate: 5.7 req / s (175.9 ms / req)
real 1m14.581s
user 0m2.497s
sys 1m7.232s
Yarv
Request rate: 55.9 req / s (17.9 ms / req)
real 0m8.960s
user 0m0.203s
sys 0m8.433s
Conclusion
I will not upset JRuby fans, but the results of such a test are not comforting.
There are also
alternative comparisons in which
JRuby is actually
3 times faster than YARV .
Correct me, please, if I am mistaken somewhere.
UPD:
In the comments correctly noted that the improvements to invokedynamic in JRuby need to include an additional option:
jruby -J-XX: + UseConcMarkSweepGC -J-XX: -UseParNewGC -Xcompile.invokedynamic = false -v config.fr
real 0m33.078s
user 0m0.930s
sys 0m31.248
Improvement by as much as two times, but still 3 times slower than YARV. Any more ideas?