Skip to content

Conversation

@Dreamacro
Copy link

The current GetProcessAffinityMask API only supports up to 64 cores on Windows.

The new implementation utilizes GetProcessGroupAffinity to retrieve the CPU group associated with the process, and GetActiveProcessorCount to determine the number of CPUs within this group. Finally, use the new SetThreadGroupAffinity to set the CPU affinity.

It is worth noting that GetThreadAffinityMask cannot obtain the affinity Mask of each thread group. It can only obtain the affinity mask of the "primary" group, so all CPUs are obtained here from GetActiveProcessorCount

Use Microsoft's official windows api binding windows-sys instead of winapi crate. These APIs support at least Windows 7 and Windows Server 2008.

It has been tested on two Sockets (two NUMA nodes) and a 13700k CPU machine.

@Dreamacro Dreamacro force-pushed the fix-windows-large-than-64 branch from 8f3adca to 7bb6955 Compare July 8, 2025 13:49
@Dreamacro Dreamacro changed the title Support large than 64 cores on WIndows Support large than 64 cores on Windows Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant