Skip to content
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

Default number of workers: Look at the affinity mask instead of the number of CPUs? #92

Open
vext01 opened this issue Dec 22, 2017 · 2 comments
Labels
2.0 Currently planed for 2.0
Projects

Comments

@vext01
Copy link

vext01 commented Dec 22, 2017

Hi,

I was looking for a thread pool, and found this repo. Thanks for working on this.

I was browsing the dependencies and saw that you use num_cpus to decide how many worker threads to use by default:

let num_threads = self.num_threads.unwrap_or_else(num_cpus::get);

Would it not be better to look into the affinity mask to get this default? The system may have 64 cores, but have the process pinned to, e.g. 4 cores. This would cause contention.

I found this crate, which might help (disclaimer, I've not used it and I'm not sure how portable it is):
https://crates.io/crates/core_affinity

Thanks

@frewsxcv
Copy link
Collaborator

from what i understand, num_cpus::get uses the affinity mask whereas num_cpus::get_physical returns the unpinned physical number of cores. i might be wrong though....

@dns2utf8
Copy link
Member

Good idea.

If you are using a SGE managed cluster you can use my latest crate son of grid engine.
You can use get_pinned_threadpool() for a correctly pinned pool there.

I think the pinning should not be the default, but an option with the builder.

@dns2utf8 dns2utf8 added this to To do in 2.0 Dec 18, 2019
@dns2utf8 dns2utf8 added the 2.0 Currently planed for 2.0 label Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 Currently planed for 2.0
Projects
2.0
  
To do
Development

No branches or pull requests

3 participants