-
Notifications
You must be signed in to change notification settings - Fork 420
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
Fix the return value of Concurrent.available_processor_count
when cpu.cfs_quota_us
is -1
#1060
Fix the return value of Concurrent.available_processor_count
when cpu.cfs_quota_us
is -1
#1060
Conversation
return nil if max == 0 | ||
# If the cpu.cfs_quota_us is -1, cgroup does not adhere to any CPU time restrictions | ||
# https://docs.kernel.org/scheduler/sched-bwc.html#management | ||
return nil if max == 0 || max == -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should check if max <= 0
?
Seems a tiny bit safer and more efficient as we can't interpret a value <= 0 safely.
Could you change to that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. I updated the condition.
Thanks and sorry for the bug. |
ddf62f6
to
7306b26
Compare
…cpu.cfs_quota_us` is -1 I tried to use `Concurrent.available_processor_count` in `parallel` gem, but we got some feedback `Concurrent.available_processor_count` returned a negative value. grosser/parallel#348 (comment) grosser/parallel#349 (comment) According to the https://docs.kernel.org/scheduler/sched-bwc.html#management, The default value of `cpu.cfs_quota_us` is -1. In that case, cgroup does not adhere to any CPU time restrictions. This PR adds the case of `cpu.cfs_quota_us` is -1 to `#cpu_quota` to return processor count from `Concurrent.available_processor_count` in that case.
7306b26
to
7fea31d
Compare
I've added a CHANGELOG entry. |
I released https://github.com/ruby-concurrency/concurrent-ruby/releases/tag/v1.3.4 with this fix |
I tried to use
Concurrent.available_processor_count
inparallel
gem, but we got some feedbackConcurrent.available_processor_count
returned a negative value.grosser/parallel#348 (comment)
grosser/parallel#349 (comment)
According to the https://docs.kernel.org/scheduler/sched-bwc.html#management, The default value of
cpu.cfs_quota_us
is -1. In that case, cgroup does not adhere to any CPU time restrictions.This PR adds the case of
cpu.cfs_quota_us
is -1 to#cpu_quota
to return processor count fromConcurrent.available_processor_count
in that case.