Ruby 3.0.0 Released, three times faster than Ruby 2

On December 25, 2020, Ruby developers announced the latest major release “Ruby 3.0.0”. It features performance improvements, especially in its speed, making it three times faster than Ruby 2.

Ruby 3.0 is the major release after Series 2, whose first version was released in 2013. The developers focused on performance, concurrency, and static analysis. As to performance, their goal was to achieve “Ruby 3X3”, in other words, triple the speed of Ruby 2, with Optcarrot benchmark.

“MJIT”, JIT compiler architecture introduced in Ruby 2.6, has been improved. It brings better performance to some workloads, such as games and AI applications that call a few methods many times. Although the size of JIT-ed code has been decreased, it is still not ready for optimizing workloads like Rails, due to the load placed on i-chache being too large.

In regards to concurrency, “Ractor” has been experimentally introduced as a parallel processing mechanism. Interactions between Ractors are now done by exchanging messages, and because objects are not shared, concurrency and parallel control can be executed without thread-safety concerns. Therefore, there are several restrictions to Ruby’s syntax when running multiple Ractors. Regarding concurrency, this release introduces Fiber#scheduler, which hooks operations that block processing like I/O. This allows for light-weight concurrency without having to change existing code.

As to static analysis, this release has added RBS, which describes the types of Ruby programs. It defines the types of classes and modules. It can also describe methods, instance variables, constants, and types. Type checkers, like TypeProf, can use it to improve the analytical accuracy of Ruby programs. Ruby 3.0 is bundled with rbs gem, which handles type definitions written in RBS. It also includes TypeProf, a type analytical tool. It serves as a kind of type inference.

There are many other new features and enhancements added to this release.

Ruby
https://www.ruby-lang.org/