Skip to content
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

FreeBSD: Add cpuset and physical core support #133

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Freaky
Copy link

@Freaky Freaky commented Apr 8, 2023

This adds support for retrieving the physical processor count by querying the kern.smp.cores sysctl, and also uses cpuset_getaffinity to determine the logical thread count. Both will fall back to the original code on failure.

❯ cargo run --example values
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/examples/values`
Logical CPUs: 16
Physical CPUs: 8
❯ cpuset -l 0-1 cargo run --example values
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/examples/values`
Logical CPUs: 2
Physical CPUs: 8
❯ cpuset -l 4-7 cargo run --example values
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/examples/values`
Logical CPUs: 4
Physical CPUs: 8

Tested on 13.1-RELEASE-p7/amd64.

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Does our current CI handle this? If not, can we add a job?

src/lib.rs Show resolved Hide resolved
@Freaky Freaky force-pushed the freebsd branch 2 times, most recently from f61e36d to efff545 Compare April 21, 2023 13:38
@@ -150,6 +152,24 @@ jobs:
rustup target add ${{ matrix.target }}
cargo build --verbose --target ${{ matrix.target }}

test-freebsd:
runs-on: macos-12
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runs-on: macos-12
runs-on: ubuntu-latest

Seems like the Ubuntu jobs are faster than mac (I assume there's a smaller quantity of them).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately VM Actions only supports macos-12, as nested virtualisation isn't available elsewhere (at least on the free tier).

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.

None yet

2 participants