Count processors across all processor groups in Etc.nprocessors - #103
Merged
Merged
Conversation
GetSystemInfo() reports the logical processors of the current processor group only, so Etc.nprocessors returned at most 64 on Windows machines with more than 64 logical processors. GetActiveProcessorCount(ALL_PROCESSOR_GROUPS) counts every group. It is looked up at runtime because mingw-w64 declares it only for _WIN32_WINNT >= 0x0601 while the mingw build targets 0x0600. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
mingw-w64 guards the macro with _WIN32_WINNT >= 0x0601 as well as the function, while the mingw build targets 0x0600. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A missing variable turned the lower bound into 0, which the existing assertion already covers. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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 Windows machines with more than 64 logical processors,
Etc.nprocessorsreturned at most 64 becauseGetSystemInfo()only counts the current processor group. It now usesGetActiveProcessorCount(ALL_PROCESSOR_GROUPS), looked up at runtime so mingw builds targeting_WIN32_WINNT0x0600 still compile.test_nprocessorsnow also checks the result againstNUMBER_OF_PROCESSORSon Windows.These commits landed in ruby/ruby first as ruby/ruby@fa3cbf9e76, ruby/ruby@17af2a8397 and ruby/ruby@41349bb1e8 (ruby/ruby#19070). I brought them here unchanged.
The CI here does not run on Windows, so I checked on x64 mswin that
rake compile testpasses. My machine has 24 logical processors in one group, so this check does not cover the more-than-64 case or the mingw build.Generated with Claude Code