core: implement bounded random sampling - #159592
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
7cf121f to
d3e55bf
Compare
I guess we should, IIRC |
d3e55bf to
8364216
Compare
|
I think I'll leave the |
…itor core: implement bounded random sampling Tracking issue: rust-lang#130703 This PR implements the `Distribution` trait for `RangeInclusive`, allowing random sampling from within a range. I chose [Lemire's algorithm](https://doi.org/10.1145/3230636), which is also used in [FreeBSD's `arc4random_uniform`](https://cgit.freebsd.org/src/tree/lib/libc/gen/arc4random_uniform.c). I've only implemented this for `core::range::RangeInclusive` to prevent typo-errors. Perhaps it makes sense though to extend the support to `core::ops::RangeInclusive`?
Rollup of 17 pull requests Successful merges: - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests) - #159130 (a bit optimize four-digit chunks in integer formatting) - #159592 (core: implement bounded random sampling) - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding)
…itor core: implement bounded random sampling Tracking issue: rust-lang#130703 This PR implements the `Distribution` trait for `RangeInclusive`, allowing random sampling from within a range. I chose [Lemire's algorithm](https://doi.org/10.1145/3230636), which is also used in [FreeBSD's `arc4random_uniform`](https://cgit.freebsd.org/src/tree/lib/libc/gen/arc4random_uniform.c). I've only implemented this for `core::range::RangeInclusive` to prevent typo-errors. Perhaps it makes sense though to extend the support to `core::ops::RangeInclusive`?
Rollup of 18 pull requests Successful merges: - #159130 (a bit optimize four-digit chunks in integer formatting) - #159592 (core: implement bounded random sampling) - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing b5be620 (parent) -> 1a833e1 (this PR) Test differencesShow 26 test diffs26 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 1a833e16546c2eb012758ddd499964fd8afee29e --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (1a833e1): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.5%, secondary -0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.5%, secondary -1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 489.76s -> 497.309s (1.54%) |
Tracking issue: #130703
This PR implements the
Distributiontrait forRangeInclusive, allowing random sampling from within a range. I chose Lemire's algorithm, which is also used in FreeBSD'sarc4random_uniform.I've only implemented this for
core::range::RangeInclusiveto prevent typo-errors. Perhaps it makes sense though to extend the support tocore::ops::RangeInclusive?