Ruby Ruby 1.9.3-p0 has just been released

huacnlee · 2011年10月30日 · 最后由 huacnlee 回复于 2012年02月04日 · 4797 次阅读

之前测过早期 rc 版本,性能有提升

这个版本的更新内容: http://svn.ruby-lang.org/repos/ruby/tags/v1_9_3_0/NEWS

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/40527

在 Ruby 1.9.2 下面,Rails 大项目明显会感觉到开发环境和启动速度缓慢,原因在于 require 的 issue,所有有人除了这个 patch : https://gist.github.com/996418

Ruby 1.9.3 的性能改进明显的地方就是修载入时间的问题。

http://www.rubyinside.com/ruby-1-9-3-faster-loading-times-require-4927.html

安装

$ cd ~/.rvm/archives $ curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.bz2 $ rvm install 1.9.3-p0 $ rvm 1.9.3-p0 $ ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

很明显的就是 Date 的效率,现在改用 C 来实现的

估计明天网上就会有性能报告出来了,大家拭目以待

先看看别人吃螃蟹

#1 楼 @Rei 额,怪了,你的回复怎么跑上面去了...

简单的测试:

./script/rails runner "puts 37337"
1.9.2-p290  ---- 16.92s user 1.43s system 69% cpu 26.423 total
ree-2011.03   ---- 11.46s user 1.23s system 70% cpu 17.955 total
1.9.3-p0  ----  7.23s user 0.59s system 98% cpu 7.942 total
patchlevel: 334, release_date: 2011-02-18, ruby_version: 1.8.7, ruby_platform: i686-darwin11.1.0
********************************************************************************
                user     system      total        real
Date.today  9.060000   0.010000   9.070000 (  9.095868)
Date.new   12.890000   0.060000  12.950000 ( 13.964456)
Array append  0.310000   0.000000   0.310000 (  0.314164)
Regexp match  0.810000   0.000000   0.810000 (  0.826616)
Random      0.100000   0.000000   0.100000 (  0.100246)
Array index  0.440000   0.000000   0.440000 (  0.483725)
Array flat  2.530000   0.030000   2.560000 (  2.681633)
Class.new   0.190000   0.000000   0.190000 (  0.197483)



patchlevel: 0, release_date: 2011-10-30, ruby_version: 1.9.3, ruby_platform: x86_64-darwin11.2.0
********************************************************************************
                 user     system      total        real
Date.today   0.700000   0.000000   0.700000 (  0.704521)
Date.new     0.480000   0.010000   0.490000 (  0.482028)
Array append  0.090000   0.000000   0.090000 (  0.095969)
Regexp match  0.890000   0.000000   0.890000 (  0.890583)
Random       0.130000   0.000000   0.130000 (  0.133199)
Array index  0.350000   0.000000   0.350000 (  0.356596)
Array flat   1.480000   0.000000   1.480000 (  1.489049)
Class.new    0.120000   0.000000   0.120000 (  0.133629)



patchlevel: 290, release_date: 2011-07-09, ruby_version: 1.9.2, ruby_platform: x86_64-darwin11.0.0
********************************************************************************
                user     system      total        real
Date.today  3.840000   0.020000   3.860000 (  4.124494)
Date.new    3.220000   0.010000   3.230000 (  3.393119)
Array append  0.080000   0.000000   0.080000 (  0.085052)
Regexp match  1.030000   0.010000   1.040000 (  1.053746)
Random      0.090000   0.000000   0.090000 (  0.092339)
Array index  0.390000   0.000000   0.390000 (  0.398123)
Array flat  1.390000   0.040000   1.430000 (  1.479191)
Class.new   0.130000   0.000000   0.130000 (  0.125919)

哇,性能提升很大阿

但是实际项目中效果不好,看数据

1.9.3-p0 的: Started GET "/topics" Completed 200 OK in 185ms (Views: 160.3ms | Mongo: 22.2ms)

Started GET "/wiki" Completed 200 OK in 52ms (Views: 48.7ms | Mongo: 2.3ms)

Started GET "/topics/6" Completed 200 OK in 116ms (Views: 90.7ms | Mongo: 19.7ms)

1.9.2 打过补丁的: Started GET "/topics" Completed 200 OK in 79ms (Views: 58.7ms | Mongo: 18.6ms)

Started GET "/wiki" Completed 200 OK in 18ms (Views: 15.7ms | Mongo: 1.8ms)

Started GET "/topics/6" Completed 200 OK in 65ms (Views: 48.4ms | Mongo: 10.0ms)

#8 楼 @huacnlee 这个要 ab -n 1000 看看阿。不过看这个数据应该差不多了。

#4 楼 @huacnlee has_many replies 在关联和 show action 都没有设 order~

#10 楼 @Rei 但我查询的时候是有 Order 的,根据 id 排序的

ruby-china 考虑用 ruby1.9.3 部署么?现在的部署速度丧心病狂阿

#13 楼 @Rei 上次试了,相比 1.9.2 响应速度要差些。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号