-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
Reduce block overhead #6005
Reduce block overhead #6005
Conversation
This is a step toward separating the unique lambda logic for blocks from the much more common normal logic. Specifically this change is intended to work toward eliminating constant checks of block type for e.g. arity checking in argument processing.
One flag was being lost due to zero arg calls not propagating the procNew flag.
There's still argument boxing happening but a couple unnecessary checks disappear in the arity != 1 paths.
Some numbers to go with this. Note that this is still only working for monomorphic blocks but expanding it to other forms will happen soon. For a simple benchmark of a Source: class Integer
def times(&block)
i = 0
while i < self
yield i
i+=1
end
end
end
loop {
t = Time.now
100_000_000.times {}
puts Time.now - t
} JRuby 9.2.9 on Java 8, no indy yield:
JRuby 9.2.9 on Java 8, with indy yield:
This PR on Java 8 (indy yield on by default):
These optimizations also help JITs like Graal optimize the entire JRuby 9.2.9 on GraalVM CE with indy yield:
This PR on GraalVM CE (with indy yield):
And because of this optimization, disabling the fixnum cache allows the loop itself to elide allocations. This PR on GraalVM CE with fixnum caching disabled:
|
Another interesting benchmark is using the native JRuby 9.2.9 on Java 8, yield from Java:
This PR on Java 8, yield from Java:
|
This PR contains several improvements to block dispatch to reduce overhead.