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
First creation of SortedSet is not thread-safe, sometimes causing load errors in Celluloid #20
Comments
Last I benchmarked it, timers was actually slower with rbtree. See some of the previous discussion here: |
I suspected as much; glad to have that out of the way. The thread-safety issue still remains though. |
Then again, ideally this would be fixed in ruby stdlib. ;) |
The workaround is a bit gross but I wouldn't mind it if it fixes the problem. Would you mind sending a PR? |
ruby/ruby#451 and https://bugs.ruby-lang.org/issues/9121 are somewhat related. But both discussions don't mention thread safety, only issues with rbtree and that terrible method. |
We have this lovely method: https://github.com/ruby/ruby/blob/ruby_2_0_0/lib/set.rb#L532
When initializing a sorted set for the first time, it will define the implementation of SortedSet, and this is not thread-safe: https://github.com/ruby/ruby/blob/ruby_2_0_0/lib/set.rb#L627
Due to this, I’ve sometimes seen an error:
Here’s a fix we’ve used to get around this, but perhaps people using the
timers
gem should not need to use this themselves:Additionally, if the gem rbtree is not available, SortedSet uses an implementation which is kind of insane. If timers uses SortedSet, it might be nice to have a gem dependency on rbtree. One might want to bench the performance in comparison to the insane implementation first, though.
The text was updated successfully, but these errors were encountered: