Skip to content

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

@vext01

Description

@vext01

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.0Currently planed for 2.0

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions