Ruby 2.6.0-rc2 Released

We are pleased to announce the release of Ruby 2.6.0-rc2.

Ruby 2.6.0-rc2 is the second release candidate of Ruby 2.6.0. RC2 is released to test bundled Bundler 1.17 instead of 2.0. It introduces some new features and performance improvements, for example:

JIT

Ruby 2.6 introduces an initial implementation of a JIT (Just-in-time) compiler.

The JIT compiler aims to improve performance of any Ruby program execution. Unlike ordinary JIT compilers for other languages, Ruby’s JIT compiler does JIT compilation in a unique way, which writes C code to a disk and spawns a common C compiler process to generate native code. See also: MJIT organization (by Vladimir Makarov).

How to use: Just specify --jit in the command line or $RUBYOPT environment variable. Specifying --jit-verbose=1 allows to print basic information of ongoing JIT compilation. See ruby --help for other options.

The main purpose of this JIT release is to provide a chance to check if it works for your platform and to find out security risks before the 2.6 release. The JIT compiler is supported when Ruby is built by GCC, Clang, or Microsoft VC++, which needs to be available at runtime. Otherwise you can’t use it for now.

As of Ruby 2.6.0-rc2, we achieved 1.7x faster performance than Ruby 2.5 on a CPU-intensive non-trivial benchmark workload called Optcarrot https://gist.github.com/k0kubun/d7f54d96f8e501bbbc78b927640f4208. We’re going to improve the performance on memory-intensive workloads like Rails applications as well.

Stay tuned for the new age of Ruby’s performance.

RubyVM::AbstractSyntaxTree [Experimental]

Ruby 2.6 introduces the RubyVM::AbstractSyntaxTree module.

This module has a parse method which parses Ruby code from a given string and returns AST (Abstract Syntax Tree) nodes, and a parse_file method which parses Ruby code from a given file and returns AST nodes. The RubyVM::AbstractSyntaxTree::Node class is also introduced. You can get location information and children nodes from Node objects. This feature is experimental. Compatibility of the structure of AST nodes is not guaranteed.

New Features

  • Add a new alias then to Kernel#yield_self. [Feature #14594]

  • else without rescue now causes a syntax error. [EXPERIMENTAL][Feature #14606]

  • Constant names may start with a non-ASCII capital letter. [Feature #13770]

  • Introduce endless ranges. [Feature #12912]

    An endless range, (1..), is introduced. It works as if it has no end. This shows typical use cases:

    ary[1..]                             # identical to ary[1..-1] without magical -1
    (1..).each {|index| block }          # infinite loop from index 1
    ary.zip(1..) {|elem, index| block }  # ary.each.with_index(1) { }
    
  • Add Binding#source_location. [Feature #14230]

    This method returns the source location of the binding, a 2-element array of __FILE__ and __LINE__. Traditionally, the same information could be retrieved by eval("[__FILE__, __LINE__]", binding), but we are planning to change this behavior so that Kernel#eval ignores binding’s source location [Bug #4352]. So, users should use this newly-introduced method instead of Kernel#eval.

  • Add :exception option to let Kernel#system raise an exception on failure instead of returning false. [Feature #14386]

  • Add a oneshot mode to Coverage. [Feature#15022]

    • This mode checks “whether each line was executed at least once or not”, instead of “how many times each line was executed”. A hook for each line is fired at most once, and after it is fired the hook flag is removed, i.e., it runs with zero overhead.
    • Add :oneshot_lines keyword argument to Coverage.start.
    • Add :stop and :clear keyword arguments to Coverage.result. If clear is true, it clears the counters to zero. If stop is true, it disables coverage measurement.
    • Coverage.line_stub, which is a simple helper function that creates the “stub” of line coverage from a given source code.
  • Add FileUtils#cp_lr. [Feature #4189]

Performance improvements

  • Speedup Proc#call because we don’t need to care about $SAFE any more. [Feature #14318]

    With lc_fizzbuzz benchmark which uses Proc#call many times we can measure x1.4 improvements. [Bug #10212].

  • Speedup block.call where block is passed block parameter. [Feature #14330]

    Ruby 2.5 improves block passing performance. [Feature #14045]

    Additionally, Ruby 2.6 improves the performance of passed block calling. With micro-benchmark we can observe x2.6 improvement.

  • Transient Heap (theap) is introduced. [Bug #14858] [Feature #14989]

    theap is a managed heap for short-living memory objects which are pointed to by specific classes (Array, Hash, Object, and Struct). For example, making a small and short-living Hash object is x2 faster. With rdoc benchmark, we observed 6-7% performance improvement.

Other notable changes since 2.5

  • $SAFE now is a process global state and can be set to 0 again. [Feature #14250]

  • Passing safe_level to ERB.new is deprecated. trim_mode and eoutvar arguments are changed to keyword arguments. [Feature #14256]

  • Supported Unicode version is updated to 11. It is planned to update to 12 and 12.1 in future TEENY releases of Ruby 2.6.

  • Merge RubyGems 3.0.0.beta3. --ri and --rdoc options were removed. Please use --document and --no-document options instead.

  • Merge Bundler as default gem.

See NEWS or the commit logs for details.

With those changes, 6411 files changed, 228864 insertions(+), 97600 deletions(-) since Ruby 2.5.0!

Enjoy programming with Ruby 2.6.0-rc2!

Download