Expand description
CPU affinity pinning for workers.
Why: on SMT-enabled CPUs (Zen 4 is 6 physical × 2 SMT = 12 logical),
unpinned workers can land on SMT siblings of the main submitter thread
and steal its cycles. That’s exactly how the previous InferencePool
attempt regressed on 6T. Pinning each worker to a distinct physical
core eliminates SMT contention.
Policies (env YSCV_POOL_AFFINITY):
none— no pinning, workers float (previous behavior).big— big / performance cores only (ARM big.LITTLE, Intel P-cores). Fallback tophysicalon symmetric CPUs.physical— one worker per physical core, one SMT sibling per core left idle for the submitter. Default on Zen 4 and other symmetric SMT CPUs.
Linux uses sched_setaffinity; macOS uses thread_policy_set with
THREAD_AFFINITY_POLICY. Other OSes fall through as a no-op.
Enums§
Functions§
- pin_
current_ thread - Pin the current thread to
cpu_id. No-op on unsupported platforms. - policy_
from_ env - Parses
YSCV_POOL_AFFINITYenv; default isphysical. - resolve_
pinning - Returns a list of CPU IDs to pin
nthreadsworkers to, sized exactlynthreads. If topology info is unavailable or policy isnone, returns an empty vec (caller should skip pinning).