-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-concurrencyArea: ConcurrencyArea: ConcurrencyB-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-SmallLibs issues that are considered "small" or self-containedLibs issues that are considered "small" or self-containedLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
The feature gate for the issue is #![feature(available_parallelism)]
.
This is a tracking issue for std::thread::available_parallelism
; a portable API to determine how many threads to spawn in order to ensure a program can make use of all available parallelism available on a machine.
Public API
#![feature(available_parallelism)]
use std::thread;
fn main() -> std::io::Result<()> {
let count = thread::available_parallelism()?.get();
assert!(count >= 1);
Ok(())
}
Tasks
- Resolve discussion on naming.
- Resolve discussion on function signature.
- Resolve discussion on terminology.
- Add support for externally-set limits on Linux (ref).
- Add support for externally-set limits on Windows (ref).
- Update documentation to remove mentions of "hardware" (ref).
- Smooth out the docs example.
Notes on Platform-specific behavior
available_parallelism
is (for now) only considered a hint. The following platform limitations exist:
- On Windows the available concurrency may be undercounted when exceeding 64 threads Add
std::thread::available_concurrency
#74480 (comment) - On Windows the available concurrency may be overcounted when limited by a process wide affinity mask or job object limitations Add
std::thread::available_concurrency
#74480 (comment) - On Linux the available concurrency may be overcounted in the face of cgroup limits and task-wise affinity masks Add
std::thread::available_concurrency
#74480 (comment)
Implementation history
- Add
std::thread::available_concurrency
#74480 - Move
available_concurrency
implementation tosys
#85182 - Make
std::thread::available_concurrency
support process-limited number of CPUs #89310 - Rename
std::thread::available_conccurrency
tostd::thread::available_parallelism
#89324 - Use cgroup quotas for calculating
available_parallelism
#92697 - Add cgroupv1 support to available_parallelism #97925
Thomasdezeeuw, bhgomes, Stranger6667 and robjtede
Metadata
Metadata
Assignees
Labels
A-concurrencyArea: ConcurrencyArea: ConcurrencyB-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-SmallLibs issues that are considered "small" or self-containedLibs issues that are considered "small" or self-containedLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.