`std::thread::available_parallelism` should respect process affinity and job object limitations
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Currently, the Windows implementation of std::thread::available_parallelism just returns the number of CPUs on the system:
This is in stark contrast to the Linux implementation, which not only checks process affinity, but also queries cgroup information. It'd be better if the Windows implementation also respected process affinity and job object limitations.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in library/std/src/sys/pal/windows/thread.rs at the linked available_parallelism implementation, then compare it with the Linux implementation's handling of process affinity and cgroup information. Investigate the Windows APIs needed to account for process affinity and job object limitations. Done means the Windows result reflects those constraints rather than only the system CPU count.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100