Usually avoid the sort in WrappingRange::smallest_range_containing - #160674
Usually avoid the sort in WrappingRange::smallest_range_containing#160674scottmcm wants to merge 1 commit into
WrappingRange::smallest_range_containing#160674Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Usually avoid the sort in `WrappingRange::smallest_range_containing`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (d0d0b8b): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf 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 1.1%, secondary -0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 460.09s -> 458.727s (-0.30%) |
|
r? @folkertdev rustbot has assigned @folkertdev. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors r+ |
|
@bors p=6 scheduling before rollup since the rollup is still small |
|
⌛ Testing commit 9704e63 with merge 5c16940... Workflow: https://github.com/rust-lang/rust/actions/runs/31316924029 |
Usually avoid the sort in `WrappingRange::smallest_range_containing` I wasn't planning on touching this [again](#160198), but I had a shower thought: we've been sorting these [for a while](https://github.com/rust-lang/rust/pull/144577/changes#diff-122bc02528abab33fa6f367f937c00f22eb4d3dc95b6a83a807576b5271ca462R776) because that's better than doing a quadratic check for usable wraparound ranges, but actually we often don't need to. So long as the obvious `min..=max` range is small enough, we don't need to bother even looking for a wrapping range! Now, I don't think this code is particularly hot -- you'd need lots of enums or particularly big ones before it would really matter -- but this does let us short-circuit for even fairly complex enums like [mem::alignment](https://github.com/rust-lang/rust/blob/88f7399cb4912680976e1c342ea7661b9dc84940/library/core/src/mem/alignment.rs#L402-L435). ---
I wasn't planning on touching this again, but I had a shower thought: we've been sorting these for a while because that's better than doing a quadratic check for usable wraparound ranges, but actually we often don't need to.
So long as the obvious
min..=maxrange is small enough, we don't need to bother even looking for a wrapping range!Now, I don't think this code is particularly hot -- you'd need lots of enums or particularly big ones before it would really matter -- but this does let us short-circuit for even fairly complex enums like mem::alignment.