Skip to content

Unfinished Ruby 3.1 features #7460

@headius

Description

@headius

This is based on #7015 and includes only the items that we did not finish in time for 9.4.0.

Language changes

  • Multiple assignment evaluation order consistency #7440 Multiple assignment evaluation order has been made consistent with single assignment evaluation order. With single assignment, Ruby uses a left-to-right evaluation order. With this code:

  • Non main-Ractors can get instance variables (ivars) of classes/modules
    if ivars refer to shareable objects.
    [Feature #17592]

Core classes updates

  • TracePoint

    • TracePoint.allow_reentry is added to allow reenter while TracePoint
      callback.
      [Feature #15912]
  • Fiber Scheduler

    • Add support for Addrinfo.getaddrinfo using address_resolve hook.
      [Feature #17370]

    • Introduce non-blocking Timeout.timeout using timeout_after hook.
      [Feature #17470]

    • Introduce new scheduler hooks io_read and io_write along with a
      low level IO::Buffer for zero-copy read/write. [Feature #18020]

    • IO hooks io_wait, io_read, io_write, receive the original IO object
      where possible. [Bug #18003]

    • Make Monitor fiber-safe. [Bug #17827]

    • Replace copy coroutine with pthread implementation. [Feature #18015]

Stdlib updates

Stdlib compatibility issues

  • lib/debug.rb is replaced with debug.gem

Implementation improvements

These do not apply directly to JRuby, but we should check if we have equivalent optimizations in place.

  • Inline cache mechanism is introduced for reading class variables.
    [Feature #17763]

  • instance_eval and instance_exec now only allocate a singleton class when
    required, avoiding extra objects and improving performance. [GH-5146]

  • The performance of Struct accessors is improved. [GH-5131]

  • mandatory_only? builtin special form to improve performance on
    builtin methods. [GH-5112]

  • Experimental feature Variable Width Allocation in the garbage collector.
    This feature is turned off by default and can be enabled by compiling Ruby
    with flag USE_RVARGC=1 set. [Feature #18045] [Feature #18239]

Debugger

  • A new debugger debug.gem is bundled.
    debug.gem is a fast debugger implementation, and it provides many features
    like remote debugging, colorful REPL, IDE (VSCode) integration, and more.
    It replaces lib/debug.rb standard library.

  • rdbg command is also installed into bin/ directory to start and control
    debugging execution.

Miscellaneous changes

  • lib/objspace/trace.rb is added, which is a tool for tracing the object
    allocation. Just by requiring this file, tracing is started immediately.
    Just by Kernel#p, you can investigate where an object was created.
    Note that just requiring this file brings a large performance overhead.
    This is only for debugging purposes. Do not use this in production.
    [Feature #17762]

  • Now exceptions raised in finalizers will be printed to STDERR, unless
    $VERBOSE is nil. [Feature #17798]

  • ruby -run -e httpd displays URLs to access. [Feature #17847]

  • Add ruby -run -e colorize to colorize Ruby code using
    IRB::Color.colorize_code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions