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

Rollup of 9 pull requests #94567

Closed
wants to merge 25 commits into from

Commits on Feb 21, 2022

  1. update docs for simplify_type

    lcnr committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    55f938b View commit details
    Browse the repository at this point in the history
  2. typo

    Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
    lcnr and lqd committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    ba2e0ca View commit details
    Browse the repository at this point in the history

Commits on Mar 2, 2022

  1. 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
    the8472 committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    bac5523 View commit details
    Browse the repository at this point in the history
  2. hardcode /sys/fs/cgroup instead of doing a lookup via mountinfo

    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
    the8472 committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    af6d2ed View commit details
    Browse the repository at this point in the history
  3. update available_parallelism docs since cgroups and sched_getaffinity…

    … are now taken into account
    the8472 committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    e18abbf View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2022

  1. Configuration menu
    Copy the full SHA
    37c1eb0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e3f04de View commit details
    Browse the repository at this point in the history
  3. Improve if/else formatting in macro_parser.rs.

    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.
    nnethercote committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    11c565f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b9fabc3 View commit details
    Browse the repository at this point in the history
  5. Introduce MatcherPosRepetition.

    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>>`!)
    nnethercote committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    643ba50 View commit details
    Browse the repository at this point in the history
  6. Use a better return type for inner_parse_loop.

    Because `inner_parse_loop` has only one way to not succeed, not three.
    nnethercote committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    e5f3fd6 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    97eb1b4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    5164884 View commit details
    Browse the repository at this point in the history
  9. add tests for rust-lang#94502

    lcnr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    188ae00 View commit details
    Browse the repository at this point in the history
  10. all: fix some typos

    Signed-off-by: cuishuang <imcusg@gmail.com>
    cuishuang committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    00fffdd View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    ff19c05 View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#92697 - the8472:cgroups, r=joshtriplett

    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
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    f776177 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#94057 - lcnr:simplify_type-uwu, r=nikomatsakis

    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
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    55ddf7d View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#94547 - nnethercote:parse_tt-cleanups, r=pe…

    …trochenkov
    
    `parse_tt` cleanups
    
    I've been looking closely at this code, and saw some opportunities to improve its readability.
    
    r? ``````@petrochenkov``````
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    c1cac49 View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#94550 - GuillaumeGomez:HKF-macros, r=notriddle

    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``
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    770a7ec View commit details
    Browse the repository at this point in the history
  16. Rollup merge of rust-lang#94551 - darnuria:doc-map-backstick, r=dtolnay

    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]);
    ```
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    0c14a12 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    aaac4f9 View commit details
    Browse the repository at this point in the history
  18. Rollup merge of rust-lang#94554 - Urgau:stmt-node-id-ice, r=petrochenkov

    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``````
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    7ea81d6 View commit details
    Browse the repository at this point in the history
  19. Rollup merge of rust-lang#94555 - cuishuang:master, r=oli-obk

    all: fix some typos
    
    Signed-off-by: cuishuang <imcusg@gmail.com>
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    bb8a82e View commit details
    Browse the repository at this point in the history
  20. Rollup merge of rust-lang#94563 - TaKO8Ki:remove-unnecessary-patten-f…

    …or-ignoring-remaining-parts, r=Dylan-DPC
    
    Remove a unnecessary `..` pattern
    matthiaskrgr committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    2894281 View commit details
    Browse the repository at this point in the history