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
Prefer IO#wait_readable
/IO#wait_writable
rather than IO.select
.
#960
Conversation
This allows the Ruby 3 scheduler hooks to improve concurrency of Redis.
0e83762
to
41c912e
Compare
I can't find any documentation on these. In which version were they introduced? Also it seems like some IOs don't have these methods, like CI shows:
|
Oh nevermind, I found them. It's part of the |
The method has been around since Ruby 2.0 at least: https://docs.ruby-lang.org/en/2.0.0/IO.html#method-i-wait_readable |
Hmmmm... It looks like However, I think we should add this method to OpenSSL gem... I'll coordinate that to happen. It will probably be the same implementation as this PR so there shouldn't be any issue. |
Sounds like it indeed. In the meantime I suppose we can feature check and use IO.select as a fallback? |
It's very trivial to delegate to the underlying I/O which is completely correct so there should be no need for |
I also noticed this:
I don't have time to investigate WHY this was a problem previously, but I don't know if the retry is needed or not. |
Do you think you can cut a release after merging this? |
It's late here, and I don't quite remember the details but:
|
Thanks for the links, if it's a bug with OpenSSL we should definitely investigate further. |
Sure, but I'd like to make sure we didn't regress on the SSL thing first. And I'll probably batch it with a couple other fixes. |
is supported in OpenSSL gem... but not sure how far back it goes (compatibility). |
Okay, looks like all tests are passing - let me know if you need anything else :) |
Should be good. Also I noticed we actually added a unit test for the SSL hanging issue, so sounds good to me. I'll merge tomorrow morning. |
…er` cop Fixes rubocop#9061. This PR adds new `Lint/IncompatibleIoSelectWithFiberScheduler` cop. It checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0. ```ruby # bad IO.select([io], [], [], timeout) # good io.wait_readable(timeout) # bad IO.select([], [io], [], timeout) # good io.wait_writable(timeout) ``` Ref: `Fiber Scheduler` section of https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/ This PR will make it possible to detect proven cases with redis/redis-rb#960.
Fixes #9061. This PR adds new `Lint/IncompatibleIoSelectWithFiberScheduler` cop. It checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0. ```ruby # bad IO.select([io], [], [], timeout) # good io.wait_readable(timeout) # bad IO.select([], [io], [], timeout) # good io.wait_writable(timeout) ``` Ref: `Fiber Scheduler` section of https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/ This PR will make it possible to detect proven cases with redis/redis-rb#960.
This allows the Ruby 3 scheduler hooks to improve concurrency of Redis.
Fixes #959