Skip to content
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

SortedSet is much slower than Hash #3476

Closed
Papierkorb opened this issue Nov 20, 2015 · 2 comments
Closed

SortedSet is much slower than Hash #3476

Papierkorb opened this issue Nov 20, 2015 · 2 comments

Comments

@Papierkorb
Copy link

Hello,

after some discussion over at #jruby, I decided to open an issue here.

A recent benchmark shows that SortedSet is much much slower than using a Hash (Mapping the set value to nil) when deleting items from it.

Full story: https://www.reddit.com/r/ruby/comments/3thkmk/doing_things_quite_fast_or_mixing_languages_or_an/

Benchmark: https://gist.github.com/Papierkorb/ab7bd6c5fdce12e3fc6c

Times from the benchmark (Taken from here)

jruby 2.2.2 java
Array
  1.270000   0.010000   1.280000 (  1.098917)
SortedSet
  1.120000   0.000000   1.120000 (  1.065251)
Hash
  0.100000   0.000000   0.100000 (  0.067120) # Roughly 16x faster

Test machine:

  • Intel i5 6600K (Skylake), 4x 3.5GHz
  • 16GiB DDR-4 memory @ 2666 MHz
@kares kares added this to the JRuby 9.2.0.0 milestone Jan 18, 2017
@kares kares self-assigned this Jun 23, 2017
@kares
Copy link
Member

kares commented Jun 27, 2017

MRI also suffers from this problem.
did not run the benchmarks but JRuby is expected will improve considerably in 9.2 with #4690

@kares kares removed their assignment Jun 27, 2017
@kares
Copy link
Member

kares commented Mar 1, 2018

while I did not run the specified benchmarks I have confirmed that using Set/SortedSet (in 9.2) operations are very close to native Java collection Set/SortedSet speed.

@kares kares closed this as completed Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants