perf(agc): pin the queue workers to the performance cores on Linux by default #626
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/626"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T08:35:08Z.
What
CpuTopology::GetandPindo nothing off Windows, soAPS5_WORKER_AFFINITY=1has no effect on Linux. This PR implements both on Linux and makes pinning the default there:Getreads the process affinity withsched_getaffinity, and the core classes from/sys/devices/cpu_core/cpus(performance) and/sys/devices/cpu_atom/cpus(efficiency). A CPU counts as hybrid only when both lists exist and are disjoint.Pinrestricts the calling thread withpthread_setaffinity_np, clipped to the process affinity. A non-null thread handle is not supported on Linux and returns 0; no caller passes one.WorkerAffinityMaskpins the queue workers, the draw front end and the presenter to the performance cores by default on Linux.APS5_NO_WORKER_AFFINITY=1opts out.APS5_WORKER_AFFINITY=1opt-in.APS5_WORKER_AFFINITY_MASK=<hex>still picks the cores on any platform.This only applies to hybrid CPUs (performance and efficiency cores, e.g. Intel 12th to 14th gen). On a non-hybrid CPU (AMD, older Intel) the kernel exposes no
cpu_core/cpu_atomlists, the layout is not hybrid, and nothing is pinned, exactly as today. The guest's own threads are never pinned. It is scheduling only; results are unchanged.Why
On my Linux kernel every CPU reports the same
cpu_capacity(1024), and there is no ITMT or per-core priority, so the scheduler treats an efficiency core like a performance core. Sampled during an unpinned run, the three hottest host threads sat on an efficiency core in 3, 7 and 4 of 40 samples; pinned, 0 of 40. Only about 2 to 2.5 cores are busy, so the performance cores are not oversubscribed.Pinning is the better default on Linux because it costs nothing where it does not apply and the gain is large where it does. PPSA21564 on a hybrid CPU, same build, pinned against unpinned, interleaved, 2 runs each (fps):
The hub level, on an earlier build, 3 runs each: 6.56 to 7.92 fps (+21%). The world map went from 26.4 to 27.5 fps (+4%, 5 and 4 runs).
Pinning the whole process instead (
taskset) was no better than pinning these threads, so only they are pinned.Before #586 (now merged), PPSA21564 hit a GPU hang (Xid 109) far more often with the workers pinned: 13 of 15 runs pinned against 0 of 3 unpinned. The hang was the per-invocation LDS array that #586 fixes; a faster worker only made it more frequent. With #586, pinned runs hung 0 times in 18.
Tested
BUILD_TESTING=ON;ctestpasses (269/269).cpu_topology(Linux only):Getreads the process affinity, and the hybrid classes do not overlap;Pinto one CPU of the process, read back withpthread_getaffinity_np;Get/Pinchecks fail against main'sCpuTopology.hpp("process affinity read") and pass with this PR.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)