Skip to main content

resolve_threads_and_affinity_in

Function resolve_threads_and_affinity_in 

Source
pub fn resolve_threads_and_affinity_in(
    requested: usize,
    topology: &CpuTopology,
) -> (usize, Vec<usize>)
Expand description

(num_threads, core_ids) for a pinned worker pool.

requested == 0 means one worker per physical core, pinned to it. An explicit count is honoured exactly, spreading across physical-core representatives first and only then across the remaining logical CPUs, so distinct hardware threads are used before any core is doubled up — filling CPUs in numeric order instead would put workers 0 and 1 on one core’s two siblings on every host that numbers siblings adjacently, i.e. half the pool contending before a second core has been touched at all. A count larger than the allowed CPU set wraps, deliberately: the caller asked for that width.