-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Rollup of 8 pull requests #94571
Rollup of 8 pull requests #94571
Conversation
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
this avoids parsing mountinfo which can be huge on some systems and something might be emulating cgroup fs for sandboxing reasons which means it wouldn't show up as mountpoint additionally the new implementation operates on a single pathbuffer, reducing allocations
… are now taken into account
To avoid the strange style where comments force `else` onto its own line. The commit also removes several else-after-return constructs, which can be hard to read.
There are three `Option` fields in `MatcherPos` that are only used in tandem. This commit combines them, making the code slightly easier to read. (It also makes clear that the `sep` field arguably should have been `Option<Option<Token>>`!)
Because `inner_parse_loop` has only one way to not succeed, not three.
Signed-off-by: cuishuang <imcusg@gmail.com>
Use cgroup quotas for calculating `available_parallelism` Automated tests for this are possible but would require a bunch of assumptions. It requires root + a recent kernel, systemd and maybe docker. And even then it would need a helper binary since the test has to run in a separate process. Limitations * only supports cgroup v2 and assumes it's mounted under `/sys/fs/cgroup` * procfs must be available * the quota gets mixed into `sched_getaffinity`, so if the latter doesn't work then quota information gets ignored too 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) } ``` strace: ``` sched_getaffinity(3041643, 32, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) = 32 openat(AT_FDCWD, "/proc/self/cgroup", O_RDONLY|O_CLOEXEC) = 3 statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address) statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=0, ...}) = 0 lseek(3, 0, SEEK_CUR) = 0 read(3, "0::/system.slice/run-u31477.serv"..., 128) = 36 read(3, "", 92) = 0 close(3) = 0 statx(AT_FDCWD, "/sys/fs/cgroup/system.slice/run-u31477.service/cgroup.controllers", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=0, ...}) = 0 openat(AT_FDCWD, "/sys/fs/cgroup/system.slice/run-u31477.service/cpu.max", O_RDONLY|O_CLOEXEC) = 3 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0 lseek(3, 0, SEEK_CUR) = 0 read(3, "300000 100000\n", 20) = 14 read(3, "", 6) = 0 close(3) = 0 openat(AT_FDCWD, "/sys/fs/cgroup/system.slice/cpu.max", O_RDONLY|O_CLOEXEC) = 3 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0 lseek(3, 0, SEEK_CUR) = 0 read(3, "max 100000\n", 20) = 11 read(3, "", 9) = 0 close(3) = 0 openat(AT_FDCWD, "/sys/fs/cgroup/cpu.max", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) sched_getaffinity(0, 128, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) = 40 ``` r? ```````@joshtriplett``````` cc ```````@yoshuawuyts``````` Tracking issue and previous discussion: rust-lang#74479
improve comments for `simplify_type` Should now correctly describe what's going on. Experimented with checking the invariant for projections but that ended up requiring fairly involved changes. I assume that it is not possible to get unsoundness here, at least for now and I can pretty much guarantee that it's impossible to trigger it by accident. r? `````@nikomatsakis````` cc rust-lang#92721
…trochenkov `parse_tt` cleanups I've been looking closely at this code, and saw some opportunities to improve its readability. r? ```````@petrochenkov```````
rustdoc: Add test for higher kinded functions generated by macros Fixes rust-lang#75564. The problem has been solved apparently so adding a test to prevent a regression. r? ```@notriddle```
Doc: Fix use of quote instead of backstick in Adapter::map. A little commit to fix documentation rendering and semantics in https://doc.rust-lang.org/std/iter/struct.Map.html#notes-about-side-effects `"` where used around an expression instead \`. Screenshot on doc.rust-lang.org: ![2022-03-03 11-21-43_backstick](https://user-images.githubusercontent.com/2827553/156546536-569b7692-7ac4-4388-8e93-c1628ddc6a0f.png) Looking forward: Maybe reworking the doc to use assert_eq like the upper paragraph: ``` let v: Vec<i32> = vec![1, 2, 3].into_iter().map(|x| x + 1).rev().collect(); assert_eq!(v, [4, 3, 2]); ```
Fix invalid lint_node_id being put on a removed stmt This pull-request remove a invalid `assign_id!` being put on an stmt node. The problem is that this node is being removed away by a cfg making it unreachable when triggering a buffered lint. The comment in the other match arm already tell to not assign a id because it could have a `#[cfg()]` so this is just respecting the comment. Fixes rust-lang#94523 r? ```````@petrochenkov```````
all: fix some typos Signed-off-by: cuishuang <imcusg@gmail.com>
…or-ignoring-remaining-parts, r=Dylan-DPC Remove a unnecessary `..` pattern
@bors r+ rollup=never p=8 |
📌 Commit cfa58df has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (40d3040): comparison url. Summary: This benchmark run did not return any relevant results. 15 results were found to be statistically significant but too small to be relevant. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Successful merges:
available_parallelism
#92697 (Use cgroup quotas for calculatingavailable_parallelism
)simplify_type
#94057 (improve comments forsimplify_type
)parse_tt
cleanups #94547 (parse_tt
cleanups)..
pattern #94563 (Remove a unnecessary..
pattern)Failed merges:
r? @ghost
@rustbot modify labels: rollup
Create a similar rollup