MINOR: Make CachingCallSite more JIT friendly #4753
Merged
+150
−99
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.
Some improvements I found when profiling the red black benchmark ( + some trivialities along the way :)):
org.jruby.RubyModule#searchWithCache(java.lang.String, boolean)
into hot and cold path methods to decrease the size of its callerorg.jruby.runtime.callsite.CachingCallSite#cacheAndCall(org.jruby.runtime.builtin.IRubyObject, org.jruby.RubyClass, org.jruby.runtime.Block, org.jruby.runtime.ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.builtin.IRubyObject)
org.jruby.runtime.callsite.CacheEntry#typeOk
and removed itsstatic
version (thestatic
version really made no sense as it required having an instance to feed into it anyhow + the instance version compiles a little smaller)updateCache(entry);
to save a byteboolean cacheAndGetBuiltin(RubyClass selfType, String methodName)
static
since it contains no reference tothis
Trivial:
@override
, where missing to improve readabilityCachingCallingSite
final
to improve readability (I make JIT converge to the final state a little faster I guess :D)private
that were needlesslyprotected
Results:
2.2%
faster for me, measured over 1k iterations6.5M
instead of6.8M