Skip to content

Unblock inlining and reduce interp_return by rewriting C methods in Ruby #493

@k0kubun

Description

@k0kubun

Background

In CRuby, many methods are written in C. This contributes to the warmup speed and the performance of the interpreter, but this could sometimes be a problem for YJIT:

  • Having a C frame in between Ruby frames prevents inlining (apply callsite-specific optimization across different methods, and possibly skip pushing/popping a CFP in inline code)
  • Not only it incurs a setjmp cost on vm_exec for every Ruby call from C, but it also causes interp_return exits on leave insn.

Idea

Rewrite C methods that call Ruby methods/blocks frequently in Ruby if that makes YJIT faster and doesn't slow down the interpreter too much in headline benchmarks. Past successful examples: ruby#3281, ruby#6983

Ones with large "block calls from C" in ruby/ruby-bench#168, e.g. Array#each, might be promising targets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions