std::thread::available_parallelism() is wrong about Windows 11/Server 2022
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
std::thread::available_parallelism() says
On Windows:
- It may undercount the amount of parallelism available on systems with more than 64 logical CPUs. However, programs typically need specific support to take advantage of more than 64 logical CPUs, and in the absence of such support, the number returned by this function accurately reflects the number of logical CPUs the program can use by default.
and per https://learn.microsoft.com/en-us/windows/win32/procthread/processor-groups#behavior-starting-with-windows-11-and-windows-server-2022 this was true before Windows 11/Server 2022, but on these and subsequent systems processes are usefully scheduled across all CPUs by default.
The implementation uses GetSystemInfo().dwNumberOfProcessors. I think GetActiveProcessorCount(ALL_PROCESSOR_GROUPS) will return the same data at full range?
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/thread/windows.rs at the available_parallelism implementation, then compare GetSystemInfo with GetActiveProcessorCount(ALL_PROCESSOR_GROUPS) and the linked Windows processor-groups guidance. Confirm the behavior on Windows 11 and Server 2022, and update the implementation or its documentation so the reported parallelism matches the supported scheduling behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100