Skip to content

RangeInclusive performance regression in beta + nightly #119643

Closed
@conradludgate

Description

@conradludgate

Code

I tried this code:

https://github.com/conradludgate/iter-num-tools/blob/024f521782cd241dea81d031cf802f22fc66bab9/benches/gridspace.rs

grid_space([1.0, 1.0]..=[100.0, 100.0], 200)

I expected to see this happen: Benchmark results to stay consistent between versions

Instead, this happened:

$ cargo +stable bench GridSpace -q
GridSpace/gridspace [1.0, 100.0] x200 (iter-num-tools)
                        time:   [114.03 µs 114.55 µs 115.19 µs]

$ cargo +beta bench GridSpace -q
GridSpace/gridspace [1.0, 100.0] x200 (iter-num-tools)
                        time:   [159.80 µs 172.22 µs 184.65 µs]
                        change: [+54.390% +64.190% +75.784%] (p = 0.00 < 0.05)
                        Performance has regressed.

$ cargo +nightly bench GridSpace -q
GridSpace/gridspace [1.0, 100.0] x200 (iter-num-tools)
                        time:   [140.26 µs 142.47 µs 144.66 µs]
                        change: [-30.426% -25.917% -20.649%] (p = 0.00 < 0.05)
                        Performance has improved.

Version it worked on

It most recently worked on:

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: aarch64-apple-darwin
release: 1.75.0
LLVM version: 17.0.6

Version with regression

rustc +beta --version --verbose:

rustc 1.76.0-beta.1 (0e09125c6 2023-12-21)
binary: rustc
commit-hash: 0e09125c6c3c2fd70d7de961bcf0e51575235fad
commit-date: 2023-12-21
host: aarch64-apple-darwin
release: 1.76.0-beta.1
LLVM version: 17.0.6

rustc +nightly --version --verbose:

rustc 1.77.0-nightly (f688dd684 2024-01-04)
binary: rustc
commit-hash: f688dd684faca5b31b156fac2c6e0ae81fc9bc90
commit-date: 2024-01-04
host: aarch64-apple-darwin
release: 1.77.0-nightly
LLVM version: 17.0.6

More info

I haven't been able to fully track down the regression, but it has something to do with RangeInclusive. Changing the benchmark to grid_space([1.0, 1.0]..[100.0, 100.0], 200) shows much less difference between versions. So far, the smallest I have reduced the repro is https://gist.github.com/conradludgate/b604d1ab0898df3babd80e384377c2b2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-propArea: Constant propagationA-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.P-mediumMedium priorityregression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions