diff options
| author | The 8472 <git@infinite-source.de> | 2022-01-09 19:39:02 +0100 |
|---|---|---|
| committer | The 8472 <git@infinite-source.de> | 2022-03-03 00:43:45 +0100 |
| commit | bac5523ea0025988361a092c1f0e7f4eb90f6ad7 (patch) | |
| tree | 825750b995d9f2c9b1c2bab49094f7196acb5673 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 8769f4ef2fe1efddd1f072485f97f568e7328f79 (diff) | |
| download | rust-bac5523ea0025988361a092c1f0e7f4eb90f6ad7.tar.gz rust-bac5523ea0025988361a092c1f0e7f4eb90f6ad7.zip | |
Use cgroup quotas for calculating `available_parallelism`
Manually tested via
```
// spawn a new cgroup scope for the current user
$ sudo systemd-run -p CPUQuota="300%" --uid=$(id -u) -tdS
// quota.rs
#![feature(available_parallelism)]
fn main() {
println!("{:?}", std::thread::available_parallelism()); // prints Ok(3)
}
```
Caveats
* cgroup v1 is ignored
* funky mountpoints (containing spaces, newlines or control chars) for cgroupfs will not be handled correctly since that would require unescaping /proc/self/mountinfo
The escaping behavior of procfs seems to be undocumented. systemd and docker default to `/sys/fs/cgroup` so it should be fine for most systems.
* quota will be ignored when `sched_getaffinity` doesn't work
* assumes procfs is mounted under `/proc` and cgroupfs mounted and readable somewhere in the directory tree
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
