-
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
Add Concurrent.available_processor_count that is cgroups aware #1038
Conversation
bfd027b
to
298d696
Compare
Arf:
I'll fix 2.3 compat. |
2ad87f7
to
aecdebb
Compare
aecdebb
to
165b061
Compare
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.
Looks good, just need a bit more documentation care.
Closes: ruby-concurrency#1035 A running gag since the introduction of containerization is software that starts one process per logical or physical core while running inside a container with a restricted CPU quota and totally blowing up memory usage in containerized environments. The proper question to ask is how many CPU cores are usable, not how many the machine has. To do that we have to read the cgroup info from `/sys`. There is two way of doing it depending on the version of cgroups used. Co-Authored-By: usiegl00 <50933431+usiegl00@users.noreply.github.com>
165b061
to
1fd2bbc
Compare
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.
Thank you!
Thanks! |
It has to be reverted because the previous implementation wasn't cgroup aware so it would often start way too many processes on various shared hosting platforms. Thanks to ruby-concurrency/concurrent-ruby#1038 concurrent-ruby 1.3 now offer a cgroups aware method to detect how many processors we can actually use.
It has to be reverted because the previous implementation wasn't cgroup aware so it would often start way too many processes on various shared hosting platforms. Thanks to ruby-concurrency/concurrent-ruby#1038 concurrent-ruby 1.3 now offer a cgroups aware method to detect how many processors we can actually use.
Thanks for this! The PR's title has a different method name than the one that landed. I added PR #1049 to fix the CHANGELOG. |
It has to be reverted because the previous implementation wasn't cgroup aware so it would often start way too many processes on various shared hosting platforms. Thanks to ruby-concurrency/concurrent-ruby#1038 concurrent-ruby 1.3 now offer a cgroups aware method to detect how many processors we can actually use.
It's a new API introduced in concurrent-ruby 1.3.1, which works better in the container environment. ruby-concurrency/concurrent-ruby#1038 Since there are gems like sorbet-runtime that still use older versions of concurrent-ruby, we can't directly bump concurrent-ruby's requirement, but need to check if the method is available before calling it.
It has to be reverted because the previous implementation wasn't cgroup aware so it would often start way too many processes on various shared hosting platforms. Thanks to ruby-concurrency/concurrent-ruby#1038 concurrent-ruby 1.3 now offer a cgroups aware method to detect how many processors we can actually use.
* Use Concurrent.usable_processor_count when it is available It's a new API introduced in concurrent-ruby 1.3.1, which works better in the container environment. ruby-concurrency/concurrent-ruby#1038 Since there are gems like sorbet-runtime that still use older versions of concurrent-ruby, we can't directly bump concurrent-ruby's requirement, but need to check if the method is available before calling it. * Update changelog
In containerized environments, a number of CPU cores isn't the same as the available CPUs. In this case, we need to consider cgroups. `concurrent-ruby` now has the method to get that since v1.3.1. I think it's better to use this for setting more container environment friendly default value. Ref: ruby-concurrency/concurrent-ruby#1038
In containerized environments, a number of CPU cores isn't the same as the available CPUs. In this case, we need to consider cgroups. `concurrent-ruby` now has the method to get that since v1.3.1. I think it's better to use this for setting more container environment friendly default value. Ref: ruby-concurrency/concurrent-ruby#1038
In containerized environments, a number of CPU cores isn't the same as the available CPUs. In this case, we need to consider cgroups. `concurrent-ruby` now has the method to get that since v1.3.1. I think it's better to use this for setting more container environment friendly default value. Ref: ruby-concurrency/concurrent-ruby#1038
In containerized environments, a number of CPU cores isn't the same as the available CPUs. In this case, we need to consider cgroups. `concurrent-ruby` now has the method to get that since v1.3.1. I think it's better to use this for setting more container environment friendly default value. Ref: ruby-concurrency/concurrent-ruby#1038
In containerized environments, a number of CPU cores isn't the same as the available CPUs. In this case, we need to consider cgroups. `concurrent-ruby` now has the method to get that since v1.3.1. I think it's better to use this for setting more container environment friendly default value. Ref: ruby-concurrency/concurrent-ruby#1038 I keep `Parallel.processor_count` as is to keep supporting setting processor count via env(`PARALLEL_PROCESSOR_COUNT`).
In containerized environments, a number of CPU cores isn't the same as the available CPUs. In this case, we need to consider cgroups. `concurrent-ruby` now has the method to get that since v1.3.1. I think it's better to use this for setting more container environment friendly default value. Ref: ruby-concurrency/concurrent-ruby#1038 I keep `Parallel.processor_count` as is to keep supporting setting processor count via env(`PARALLEL_PROCESSOR_COUNT`).
In containerized environments, a number of CPU cores isn't the same as the available CPUs. In this case, we need to consider cgroups. `concurrent-ruby` now has the method to get that since v1.3.1. I think it's better to use this for setting more container environment friendly default value. Ref: ruby-concurrency/concurrent-ruby#1038 I keep `Parallel.processor_count` as is to keep supporting setting processor count via env(`PARALLEL_PROCESSOR_COUNT`).
It has to be reverted because the previous implementation wasn't cgroup aware so it would often start way too many processes on various shared hosting platforms. Thanks to ruby-concurrency/concurrent-ruby#1038 concurrent-ruby 1.3 now offer a cgroups aware method to detect how many processors we can actually use.
… count (We already require concurrent-ruby 1.3.1+ with support for this.) References: * rails@f719787 * ruby-concurrency/concurrent-ruby#1038
Hi! The PR title says the new API was named Would someone mind updating the PR title to match? |
Closes: #1035
A running gag since the introduction of containerization is software that starts one process per logical or physical core while running inside a container with a restricted CPU quota and totally blowing up memory usage in containerized environments.
The proper question to ask is how many CPU cores are usable, not how many the machine has. To do that we have to read the cgroup info from
/sys
. There is two way of doing it depending on the version of cgroups used.Co-Authored-By: @usiegl00