Wednesday, 28 November 2012

ruby 1.9.3 perfomance

Hi,

Recently I have read article about ruby performance issue compared to ruby 1.9.2 and ruby 1.9.3 and came to see few important points that need to be noted. Below is the discussion.

We just switched a site from Apache + ruby 1.9.2 to nginx + ruby 1.9.3 a few days ago and I noticed that somehow the site speed has noticably dropped on the ruby side of things and I just couldn’t understand why.

/opt/nginx/logs# rvm use 1.9.3
Using /usr/local/rvm/gems/ruby-1.9.3-p327
/opt/nginx/logs# time ruby -e "count = 0; while(count < 100000000); count = count + 1; end; puts count"
100000000
real 0m7.655s
user 0m7.632s
sys 0m0.012s
/opt/nginx/logs# rvm use 1.9.2
Using /usr/local/rvm/gems/ruby-1.9.2-p320
/opt/nginx/logs# time ruby -e "count = 0; while(count < 100000000); count = count + 1; end; puts count"
100000000
real 0m4.716s
user 0m4.716s
sys 0m0.000s
Checking make.log showed that 1.9.3 was indeed compiled w/o any optimizations. After I hand-compiled a 1.9.3, I got this:

/opt/ruby193opt/bin# ./ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
/opt/ruby193opt/bin# time ./ruby -e "count = 0; while(count < 100000000); count = count + 1; end; puts count"
100000000
real 0m4.641s
user 0m4.628s
sys 0m0.008s
/opt/ruby193opt/bin# ruby -v
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-linux]
puck352:/opt/ruby193opt/bin# time ruby -e "count = 0; while(count < 100000000); count = count + 1; end; puts count"
100000000
real 0m4.634s
user 0m4.624s
sys 0m0.012s
Now it performs on par with 1.9.2
 Thank You,
Uma Mahesh.



No comments:

Post a Comment