-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unblock inlining and reduce interp_return by rewriting C methods in Ruby #493
Comments
Array#eachWhen I started working on this, rewriting
The Ruby PR currently uses microbenchmark# --yjit-call-threshold=1
def bench(arr)
i = 0
arr.each do |a|
i += a
end
i
end
bench([1, 1]) # JIT
Time.now # JIT
arr = Array.new(50000000)
arr.map! { 1 }
t = Time.new
bench(arr)
p(Time.new - t)
railsbench
--yjit-stats beforemaster (86de48e9f6)
--yjit-stats afterRewrite Array#each in Ruby + YJIT: Consider a block ISEQ in block versioning (224c1f2f17 w/
stats without "YJIT: Consider a block ISEQ in block versioning"
If you compare "--yjit-stats after" and "stats without YJIT: Consider a block ISEQ in block versioning", you can see ruby#7247 contributes to significantly reducing This reduces the amount of While we could still work on reducing cc: @maximecb |
Just to make sure I understand: you added a block iseq parameter to the context. This keeps track of the ISEQ of the block parameter to the function (if known). What is the With respect to versioning on the input block ISEQ, I feel like maybe this isn't ideal. It seems like we're pushing versioning information from the caller into the callee in order to specialize it, but functions like Ultimately, our goal is to inline |
Correct. I haven't investigated when
I agree that it's better to associate the versioning limit to the caller of |
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:
vm_exec
for every Ruby call from C, but it also causesinterp_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 Shopify/yjit-bench#168, e.g.
Array#each
, might be promising targets.The text was updated successfully, but these errors were encountered: