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.

rubylogo2a

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.

ruby 3 benchmark

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.

rubylogo2a

More Information

Ruby Official Site

Related Articles

Fukuoka Ruby Award 2021 Prestigious Ruby Prize

Ruby 2.6 Adds JIT Compiler

Sorbet - Making Ruby Statically Typed

Ruby 2.5 Adds Support For Branch Coverage

Commercial Ruby Distro Enters Beta

Ruby On Rails Reaches 5.0

Ruby 2.3 Released

ActiveState Extends to Ruby, Node.js, Go and Lua

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, Facebook or Linkedin.

Banner


Coursera For New Year-Long Opportunity
30/12/2020

Coursera, the online course provider which partners with leading universities and companies to deliver courses, certificates and even degrees has a great offer to welcome in 2021 - over $100 off a Cou [ ... ]



JupyterLab 3 Released
11/01/2021

A major new version of JupyterLab has been released with new features for users and substantial improvements to the extension system.


More News

square

 



 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 31 December 2020 )