-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Set/Array #include? performance degradation #3389
Comments
Worth a gander. |
I do not think this is likely a slowdown in Array#nclude? (I did not check Set) but in IR and its processing of blocks: a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
require "benchmark/ips"
Benchmark.ips do |x|
x.config(:time => 10, :warmup => 5)
x.report("Array#include?") do
a.include?(8)
a.include?(8)
a.include?(8)
a.include?(8)
a.include?(8)
a.include?(8)
a.include?(8)
a.include?(8)
a.include?(8)
a.include?(8)
end
x.report("times do") do
1_000_000.times do
a.include?(8)
end
end
x.report("while do") do
i = 0
while i < 1_000_000
a.include?(8)
i += 1
end
end
end for 1.7:
For 9k:
In completely unrolled loop we are <10% difference with 1.7 winning. With 'times' we are significantly slower on 9k so there is something we are not opting well in empty loop. For a simple while you can see 9k actually runs things faster. So I suspect neither Array nor Set methods are to blame but our block overhead. |
My numbers for Integer#times were better than @enebo's and only about 10% off from 1.7. This is a known regression in overall block dispatch performance that we have plans to fix. On my system, Array#include? also has nearly identical performance between 1.7 and 9k, so I don't think there's anything to fix for this bug. Block perf is a known issue and will be improved in future releases of 9k. |
I finally updated to u60 and I see the same perf difference as @headius now. |
upgrading to u60 also resolved this perf diff on my machine, thanks! |
Between Jruby-1.7.20.1 and JRuby-9.0.1.0 there seems to be a significant degradation in the performance of Array and Set #include? methods along with other Enumerable methods (select/reject) that we can't seem to come up with a plausible explanation as to why (as we have looked through the code)
It looks as if the performance has been cut in half with respect to these methods
JRuby-1.7.20.1 (Array#include?)
JRuby-9.0.1.0 (Array#include?)
JRuby-1.7.20.1 (Set#include?)
JRuby-9.0.1.0 (Set#include?)
The text was updated successfully, but these errors were encountered: