Skip to content

[pull] master from ruby:master#1189

Merged
pull[bot] merged 8 commits into
turkdevops:masterfrom
ruby:master
Jul 7, 2026
Merged

[pull] master from ruby:master#1189
pull[bot] merged 8 commits into
turkdevops:masterfrom
ruby:master

Conversation

@pull

@pull pull Bot commented Jul 7, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

luke-gruber and others added 8 commits July 7, 2026 09:54
This is an often-called internal function that has a fastpath, so the fastpath
should be inlined.

Benchmark:

```ruby
require 'benchmark/ips'

ARR = [1, 2, 3]

Benchmark.ips(quiet: true) do |x|
  x.config(time: 2, warmup: 1)

  # Control: C method, does not route through rb_check_convert_type_with_id. Detects drift.
  x.report("control itself") do |t|
    a = ARR
    i = 0; while i < t; a.itself; i += 1; end
  end

  # Target: Array(arr) -> rb_Array -> rb_check_array_type -> inlined RB_TYPE_P fast path
  x.report("Array(arr)") do |t|
    a = ARR
    i = 0; while i < t; Array(a); i += 1; end
  end
end
```

When run 10 times, we see a 4% average improvement.
Mirror much more closely the parse.y COND and CMDARG stacks. This
fixes a whole host of really really weird edge cases.

ruby/prism@75bf2e7081
Make block#[], block#yield, block#=== faster when inside a method and the block is a
block parameter. Treat it like an optimized method just like block#call was already.
This avoids the proc allocation unless the method is redefined.

```
Summary (YJIT disabled):

┌──────────────────────┬────────────┬────────────┬─────────────────────────────────┐
│          op          │   before   │   after    │             speedup             │
├──────────────────────┼────────────┼────────────┼─────────────────────────────────┤
│ block.call (control) │ 8.287M i/s │ 8.298M i/s │ ~1.00× (unchanged, as expected) │
├──────────────────────┼────────────┼────────────┼─────────────────────────────────┤
│ block[]              │ 3.786M i/s │ 8.289M i/s │ ~2.19×                          │
├──────────────────────┼────────────┼────────────┼─────────────────────────────────┤
│ block.yield          │ 3.760M i/s │ 8.269M i/s │ ~2.20×                          │
└──────────────────────┴────────────┴────────────┴─────────────────────────────────┘

Summary (YJIT enabled)

┌──────────────────────┬─────────────┬─────────────┬────────────────────┐
│          op          │   before    │    after    │      speedup       │
├──────────────────────┼─────────────┼─────────────┼────────────────────┤
│ block.call (control) │ 32.736M i/s │ 32.749M i/s │ ~1.00× (unchanged) │
├──────────────────────┼─────────────┼─────────────┼────────────────────┤
│ block[]              │ 9.112M i/s  │ 32.012M i/s │ ~3.51×             │
├──────────────────────┼─────────────┼─────────────┼────────────────────┤
│ block.yield          │ 9.119M i/s  │ 32.683M i/s │ ~3.58×             │
└──────────────────────┴─────────────┴─────────────┴────────────────────┘
```
If number of keyword arguments are not taken into account when comparing CI
shapes, invalid bindings happen:

```
class Foo
  def bar(a: nil, b: nil)
    p [:body, a: a, b: b]
  end
end

foo = Foo.new

foo.bar(a: 1, b: 2)   #=> [:body, {a: 1, b: 2}] # prime CC
foo.bar(99, a: 0)     #=> [:body, {a: 99, b: nil}] # BAD!
```

Also, set max keywords to 2**16-1 so we don't grow the cc_entries_entry struct.

Fixes [Bug #22099]
We do it once per `compile`, meaning once per `jit_jit` stub, so we
should see how much time this is actually taking up.
Some code runs before options are setup or needs to support a
non-initialize Ruby VM (for example, for tests). Allow plumbing through
a default option in that case.
We do it frequently, so we should see how much time this is actually
taking up.
@pull pull Bot locked and limited conversation to collaborators Jul 7, 2026
@pull pull Bot added the ⤵️ pull label Jul 7, 2026
@pull pull Bot merged commit 6ab9983 into turkdevops:master Jul 7, 2026
1 of 3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants