-
Notifications
You must be signed in to change notification settings - Fork 476
FreeBSD: Improve CPU core count handling #904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CC @kevans91 |
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable, thanks!
This improves the CPU core count handling for FreeBSD. This uses sysconf to grab the number of configured processors when logical and physical CPU counts are requested, and then pthread_getaffinity_np and the number of active processors. This takes into account the number of available cores when the process is restricted to a subset of the processors. This also fixes the `dispatch_workqueye` test, which has its own implementation to extract the core count. FreeBSD does not have an `hw.activecpu` syscall, so the syscallbyname was failing and the activecpu count was garbage from the stack. I've updated the test to initialize the value with `0xa1a1a1` to make the garbage clearer. Also update the test for FreeBSD to take advantage of sysconf and pthread_getaffinity_np in the test. Fixes: swiftlang#897
558886c
to
ea88133
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, for what that's worth. Happy to look a little bit closer if there's still something off with the test (I haven't tried to run it yet, personally).
Thanks for your help. I’ve checked on my FreeBSD box, and all tests are passing with this change. |
@swift-ci please test Windows |
This improves the CPU core count handling for FreeBSD. This uses sysconf to grab the number of configured processors when logical and physical CPU counts are requested, and then pthread_getaffinity_np and the number of active processors. This takes into account the number of available cores when the process is restricted to a subset of the processors.
This also fixes the
dispatch_workqueye
test, which has its own implementation to extract the core count. FreeBSD does not have anhw.activecpu
syscall, so the syscallbyname was failing and the activecpu count was garbage from the stack. I've updated the test to initialize the value with0xa1a1a1
to make the garbage clearer. Also update the test for FreeBSD to take advantage of sysconf and pthread_getaffinity_np in the test.Fixes: #897