Currently, the Windows implementation of std::thread::available_parallelism just returns the number of CPUs on the system:
|
pub fn available_parallelism() -> io::Result<NonZero<usize>> { |
|
let res = unsafe { |
|
let mut sysinfo: c::SYSTEM_INFO = crate::mem::zeroed(); |
|
c::GetSystemInfo(&mut sysinfo); |
|
sysinfo.dwNumberOfProcessors as usize |
|
}; |
|
match res { |
|
0 => Err(io::Error::UNKNOWN_THREAD_COUNT), |
|
cpus => Ok(unsafe { NonZero::new_unchecked(cpus) }), |
|
} |
|
} |
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.
Currently, the Windows implementation of
std::thread::available_parallelismjust returns the number of CPUs on the system:rust/library/std/src/sys/pal/windows/thread.rs
Lines 126 to 136 in e3fccdd
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.