Provide a collector for indy varargs boxing#6630
Merged
headius merged 3 commits intojruby:masterfrom Mar 26, 2021
Merged
Conversation
Member
Author
|
Performance of modified require 'benchmark/ips'
puts RUBY_DESCRIPTION
array = [[[[[[[[[[[14]]]]]]]]]]]
Benchmark.ips do |x|
x.report('dig-01') {|i| while i>0; i-=1; array.dig(0); end }
x.report('dig-02') {|i| while i>0; i-=1; array.dig(0, 0); end }
x.report('dig-03') {|i| while i>0; i-=1; array.dig(0, 0, 0); end }
x.report('dig-04') {|i| while i>0; i-=1; array.dig(0, 0, 0, 0); end }
x.report('dig-05') {|i| while i>0; i-=1; array.dig(0, 0, 0, 0, 0); end } # easy to find examples this long
x.report('dig-06') {|i| while i>0; i-=1; array.dig(0, 0, 0, 0, 0, 0); end }
x.report('dig-07') {|i| while i>0; i-=1; array.dig(0, 0, 0, 0, 0, 0, 0); end }
x.report('dig-08') {|i| while i>0; i-=1; array.dig(0, 0, 0, 0, 0, 0, 0, 0); end } # possible to find examples this long
x.report('dig-09') {|i| while i>0; i-=1; array.dig(0, 0, 0, 0, 0, 0, 0, 0, 0); end }
x.report('dig-10') {|i| while i>0; i-=1; array.dig(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); end }
x.compare!
endNo indy: With indy, before: With indy, after: |
Merged
Member
Author
|
Ran into an issue running optcarrot: |
Member
Author
|
The issue in optcarrot was due to indy binding method_missing with the wrong number of arguments after my change. The arity of the method_missing call and the arity of the collector did not match. I added a spec for a zero-arity method_missing call which will catch this issue in the future. This is ready (again). |
It turns out that MethodHandle.asCollector is very slow for subclasses of Object[] due to double-allocation and double-copying done by the OpenJDK logic. To avoid this overhead, we use 10-wide overloads of our own collector utility functions and pass to Binder.collect, which now supports the MethodHandles.collectArguments decorator. Fixes jruby#6628
Would have caught the method_missing glitch
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It turns out that MethodHandle.asCollector is very slow for
subclasses of Object[] due to double-allocation and double-copying
done by the OpenJDK logic. To avoid this overhead, we use 10-wide
overloads of our own collector utility functions and pass to
Binder.collect, which now supports the
MethodHandles.collectArguments decorator.
Fixes #6628