[pull] master from ruby:master#1189
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 : )