|Ruby 3 Released Offering Three Times Better Performance|
|Written by Kay Ewbank|
|Thursday, 31 December 2020|
Ruby 3 has been released. This major new version has goals of improving performance, concurrency and support for Typing. The headline improvement is the performance, with Yukihiro Matsumoto, aka Matz, the chief designer of Ruby, saying that Ruby 3 will be three times faster than Ruby 2.
Ruby has gained popularity because, in addition to being fun to use, it is useful because of its mix of different programming styles - functional, dynamic and object-oriented.
Tests run using the Optcarrot benchmark, which measures single thread performance based on NES’s game emulation workload, Ruby 3 has shown the promised three times faster performance than Ruby 2.0.
The performance is achieved by Ruby 3.0 when used in JIT mode. This is new in Ruby 3, and should provide performance improvements in limited workloads, such as games, AI, and other applications where the majority of the time is spent in calling a few methods many times. The developers say that while Ruby 3.0 has significantly decreased the size of JIT-ed code, it is still not ready for optimizing workloads like Rails, which often spend time on many methods and therefore suffer from i-cache misses. This will be exacerbated by JIT, so the performance will actually be worse. The developers say Ruby 3.1 will offer further improvements on this issue.
Another area that has helped performance is the move to add better concurrency support. The new release adds experimental support for Ractor, as well as Async Fiber. Ractor is an Actor-model like concurrent abstraction that can provide a parallel execution feature without thread-safety concerns. This is achieved because ractors don't share normal objects; communication between ractors is supported by exchanging messages.
The experimental nature of Ractor means the specification and implementation may be changed in the future.
Fiber Scheduler has also been introduced for intercepting blocking operations. This allows for lightweight concurrency without changing existing code.
Other improvements add support for static typing. The developers have created a “foundational type signature language” called RBS, which is used to describe the types of Ruby programs. The idea is that RBS will support commonly seen patterns in Ruby programs and will allow developers to create advanced types including union types, method overloading, and generics. It also supports duck typing with interface types.
Ruby 3.0 ships with the rbs gem, which allows parsing and processing type definitions written in RBS. The Ruby team says type checkers including TypeProf and other tools supporting RBS will understand Ruby programs much better with RBS definitions.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Thursday, 31 December 2020 )|