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

openbsd: available_parallelism: use the right API #119436

Merged
merged 1 commit into from Dec 30, 2023

Conversation

semarie
Copy link
Contributor

@semarie semarie commented Dec 30, 2023

use the standard sysconf(_SC_NPROCESSORS_ONLN) way to get the number of available processors (capable of running processes), and fallback to sysctl([CTL_HW, HW_NCPU]) (number of CPUs configured) only on error.

it permits to differenciate CPUs online (capable of running processes) vs CPUs configured (not necessary capable of running processes).

while here, use the common code path for BSDs for doing that, and avoid code duplication.

Problem initially reported to me by Jiri Navratil.

use the standard sysconf(_SC_NPROCESSORS_ONLN) way to get the number of 
available processors (capable of running processes), and fallback to 
sysctl([CTL_HW, HW_NCPU]) (number of CPUs configured) only on error.

it permits to differenciate CPUs online vs CPUs configured (and not necessary 
capable of running processes).

while here, use the common code path for BSDs for doing that, and avoid code 
duplication.

Problem initially reported to me by Jiri Navratil.
@rustbot
Copy link
Collaborator

rustbot commented Dec 30, 2023

r? @thomcc

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 30, 2023
@semarie
Copy link
Contributor Author

semarie commented Dec 30, 2023

as side note, I am the designated developer for OpenBSD in rust.

@semarie
Copy link
Contributor Author

semarie commented Dec 30, 2023

@rustbot label -O-unix O-openbsd

@rustbot rustbot added O-openbsd Operating system: OpenBSD and removed O-unix Operating system: Unix-like labels Dec 30, 2023
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

r? @Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Dec 30, 2023

📌 Commit 3633f8b has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rustbot rustbot assigned Mark-Simulacrum and unassigned thomcc Dec 30, 2023
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2023
bob-beck pushed a commit to openbsd/ports that referenced this pull request Dec 30, 2023
see rust-lang/rust#119436

it makes std::thread::available_parallelism to use sysconf(_SC_NPROCESSORS_ONLN)
and only fallback to sysctl([CTL_HW, HW_NCPU]).

Problem reported by Jiri Navratil
@bors
Copy link
Contributor

bors commented Dec 30, 2023

⌛ Testing commit 3633f8b with merge a2541e8...

@bors
Copy link
Contributor

bors commented Dec 30, 2023

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing a2541e8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 30, 2023
@bors bors merged commit a2541e8 into rust-lang:master Dec 30, 2023
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Dec 30, 2023
@semarie semarie deleted the openbsd-available_parallelism branch December 30, 2023 18:08
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a2541e8): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-3.1%, -1.0%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.1% [-3.1%, -1.0%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.7% [3.0%, 4.4%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 669.011s -> 668.901s (-0.02%)
Artifact size: 311.79 MiB -> 311.80 MiB (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. O-openbsd Operating system: OpenBSD S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants