Add Windows support for CPU affinity for >64 CPUs.#817
Merged
Disservin merged 1 commit intoDisservin:masterfrom Mar 17, 2025
Merged
Add Windows support for CPU affinity for >64 CPUs.#817Disservin merged 1 commit intoDisservin:masterfrom
Disservin merged 1 commit intoDisservin:masterfrom
Conversation
On supported Windows platforms (Win11 or Server 2022), use newer APIs to set CPU affinity correctly when there are more than 64 logical CPUs. Fixes /Disservin#816.
Contributor
Author
|
Note I built the Windows binary using: And the toolchain was installed from the msys2 shell using: I'm not sure if the current Github workflow is configured correctly to use the UCRT. If building with a toolchain targeting an older Windows C runtime, the changes may fail to compile due to If a maintainer approves the workflow run, I guess we will see. |
Disservin
reviewed
Mar 16, 2025
Owner
|
Wow! Thanks a lot for diagnosing this and fixing it :D |
Owner
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On supported Windows platforms (Win11 or Server 2022), use newer APIs to set CPU affinity correctly when there are more than 64 logical CPUs.
Resolves #816, at least for those newer Windows platforms.
With this change, running concurrency 64 on a 7980X (64 cores, 128 SMT threads) on Windows 11 and enabling CPU affinity now results in the expected CPU utilization:

As you can see, the first logical CPU of each of the 64 physical cores is now being utilized. This results in better and more consistent performance.
I've also validated that the app still works on Windows 10 (where
SetProcessDefaultCpuSetMasksis not available), both with and without setting CPU affinity. Note that the Windows 10 system is a 4 core / 8 thread machine. I don't think testing on a >64 thread Windows 10 system is required.