-
Notifications
You must be signed in to change notification settings - Fork 271
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
Unsafe concurrent Hash access #514
Comments
An alternative would be to use a Mutex around all accesses to these global Hash'es. |
Because I looked it up I'll note that those were introduced with 880b34c |
Would that help even before ruby-concurrency/concurrent-ruby#970 is addressed? |
Yes, the only thing I meant by that link is one should use that |
Right, so the way to address this (with |
Yes |
More comments by @byroot at oracle/truffleruby#3166 (comment) |
@byroot Any chance you could take a look at this? :) It'd be good to figure out what's the desired solution for |
I was quite busy lately. I'll try to find some time to dig into this next week. |
Fix: sporkmonger#514 Fix: oracle/truffleruby#3166 These hashes lazily memoize percent encoded characters, this is an issue on GVL-less Ruby implementations as it can cause concurrent access. But these are actually quite wastful as the key is always a single byte so rather than use string keys are lazily memoize these, we can precompute two static arrays of 255 elements once and for all.
Fix: sporkmonger#514 Fix: oracle/truffleruby#3166 These hashes lazily memoize percent encoded characters, this is an issue on GVL-less Ruby implementations as it can cause concurrent access. But these are actually quite wastful as the key is always a single byte so rather than use string keys are lazily memoize these, we can precompute two static arrays of 255 elements once and for all.
Fix: sporkmonger#514 Fix: oracle/truffleruby#3166 These hashes lazily memoize percent encoded characters, this is an issue on GVL-less Ruby implementations as it can cause concurrent access. But these are actually quite wastful as the key is always a single byte so rather than use string keys are lazily memoize these, we can precompute two static arrays of 255 elements once and for all.
Fix: sporkmonger#514 Fix: oracle/truffleruby#3166 These hashes lazily memoize percent encoded characters, this is an issue on GVL-less Ruby implementations as it can cause concurrent access. But these are actually quite wastful as the key is always a single byte so rather than use string keys are lazily memoize these, we can precompute two static arrays of 255 elements once and for all.
Fix: #514 Fix: oracle/truffleruby#3166 These hashes lazily memoize percent encoded characters, this is an issue on GVL-less Ruby implementations as it can cause concurrent access. But these are actually quite wasteful as the key is always a single byte so rather than use string keys are lazily memoize these, we can precompute two static arrays of 255 elements once and for all. Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
It happens for SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE and SEQUENCE_ENCODING_TABLE
See oracle/truffleruby#3166 (comment)
This happens on TruffleRuby and possibly on JRuby.
On CRuby the error will not happen due to the GIL.
On CRuby it may still cause duplicate computation and assignment for the same key.
A good solution would be to use a Concurrent::Map from
concurrent-ruby
instead of rawHash
there.And the same for SEQUENCE_ENCODING_TABLE just above.
(as a note, this is the correct pattern: ruby-concurrency/concurrent-ruby#970)
Then it's fast on CRuby and is thread-safe and scales on no-GVL Rubies.
Of course this would add a dependency on
concurrent-ruby
for this gem.The text was updated successfully, but these errors were encountered: