-
Notifications
You must be signed in to change notification settings - Fork 419
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
Concurrent::Map Performance #882
Comments
the test is wrong and the fact, that it's only 2 times slower shows a great job done by ruby team! |
Thanks for replay. "Map A hash-like object that should have much better performance characteristics, especially under high concurrency, than Concurrent::Hash." I see a lot of Concurrent::Map usage in some open source project but why should anybody use it if Concurrent::Hash is faster ? |
@kvokka What do you mean? There is no Array involved in Concurrent::Map as far as I can see. @totrash It's a fair question. Now the point about Concurrent::Map is it enables concurrent/parallel access to the map but for that you need a Ruby implementation without a global lock, so JRuby or TruffleRuby. CRuby never executes Ruby code in parallel (well except Ractors). So use Concurrent::Hash when you need ordering, and use Concurrent::Map when you don't need ordering. |
With #989 there is almost no difference for |
I tried to use Concurrent::Map instead of Concurrent::Hash because I don't need ordered Hash and I suppose that this is the main difference between them.
Unfortunately, my tests show that Map is generally slower especially on writing
Am I understand it right that Concurrent::Map is created for better performance when You don't need ordered inserts in Hash ?
My tests full code
Results
Results with concurrent-ruby-ext
One simple test of reading/writing/deleting operations looks like this:
And here are some results:
With concurrent-ruby-ext installed results are similar.
The text was updated successfully, but these errors were encountered: