Ruby Ruby 3.0.0 Released

putaozhenhaochi · 2020年12月25日 · 最后由 ppp8863 回复于 2021年05月12日 · 9332 次阅读

喜大普奔

Concurrency / Parallel

It’s multi-core age today. Concurrency is very important. With Ractor, along with Async Fiber, Ruby will be a real concurrent language. — Matz

huacnlee 回复

3.0 的并发支持多核了么?谁知道哪里有参考资料,发来看看

🎉🎉🎉

👏👏👏

huacnlee 回复

文档中提及在 4 核心并行 处理的时候,性能是单核处理的 3.87 倍

def tarai(x, y, z) =
  x <= y ? y : tarai(tarai(x-1, y, z),
                     tarai(y-1, z, x),
                     tarai(z-1, x, y))
require 'benchmark'
Benchmark.bm do |x|
  # sequential version
  x.report('seq'){ 4.times{ tarai(14, 7, 0) } }

  # parallel version
  x.report('par'){
    4.times.map do
      Ractor.new { tarai(14, 7, 0) }
    end.each(&:take)
  }
end

Benchmark result:
          user     system      total        real
seq  64.560736   0.001101  64.561837 ( 64.562194)
par  66.422010   0.015999  66.438009 ( 16.685797)

The result was measured on Ubuntu 20.04, 
Intel(R) Core(TM) i7-6700 (4 cores, 8 hardware threads). 
It shows that the parallel version is 3.87 times faster than the sequential version.
huacnlee 回复

然后又看了 ractor 的文档

https://github.com/ruby/ruby/blob/master/doc/ractor.md

从标红的地方来看,在同一个 ractor 内的线程因为有 Ractor-wide global lock 类似 GIL 锁 不能实现多核并发,但多个 ractor之前是可以实现多核并发

rails 6.1 在 ruby3 下跑没问题吧

🎉 🎉 🎉 恭喜达成新的里程碑

恭喜恭喜😀

每年的圣诞礼物来了🎉 🎉 🎉

大哥大嫂过年好!

期待已久。🎉🎉🎉

充实的圣诞 🎉 🎉

huacnlee 回复

你这一如既往的神速啊

不知道为何 ruby 要把很多有用的库从标准库中移走真实反潮流。开箱即用的功能越来越少了。这点很不好。

lilijreey 回复

@lilijreey

有很多吗?? 🙄

https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/

The following libraries are no longer bundled gems or standard libraries. Install the corresponding gems to use these features.
sdbm
webrick
net-telnet
xmlrpc

为什么我在 Linux 里使用 rvm list known,没有 3.0.0 版本的,但是在 Mac 里有?

charlie_hsieh 回复

SortedSet 也没了

38 楼 已删除
992699452 回复

更新一下 rvm

zhongsheng 回复

看起来,rvm 还是有人在使用,目前很多教程都以 rbenv 为主,我都很担心,rvm 作者会撑不下去。

👏 👏 👏

为啥 3.0.0 后没有动作了。。。

macOS Big Sur 默认的版本才 ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20] 什么时候可以默认安装到 3.0.0

3.0.1 出来了 同志们去更新呀

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