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

Iterator performance regression 1.81 -> 1.82 #137727

Open
Sunshine40 opened this issue Feb 27, 2025 · 4 comments
Open

Iterator performance regression 1.81 -> 1.82 #137727

Sunshine40 opened this issue Feb 27, 2025 · 4 comments
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Sunshine40
Copy link
Contributor

Code

I tried this code:

use std::time::Instant;

fn main() {
    let start = Instant::now();

    (0..=1000)
    .flat_map(|a| {
        (0..=1000).flat_map(move |b| {
            (0..=1000)
                .filter(move |&c| a * a + b * b == c * c && a + b + c == 1000)
                .map(move |c| (a, b, c))
        })
    })
    .for_each(|(a, b, c)| {
        println!("a: {} b: {} c: {}", a, b, c);
    });

    let duration = start.elapsed();
    println!("{} seconds", duration.as_secs_f64());
}

I expected to see this happen: code behaves the same across compiler versions

Instead, this happened: code runs 80% slower when compiled with Rust 1.82+

Version it worked on

It most recently worked on: Rust 1.81

Version with regression

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-pc-windows-msvc
release: 1.82.0
LLVM version: 19.1.1

More details in this post

https://internals.rust-lang.org/t/iterator-performance-regression-1-81-1-82/22473

@Sunshine40 Sunshine40 added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Feb 27, 2025
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 27, 2025
@Sunshine40
Copy link
Contributor Author

I wonder if this is somehow related to #132636?

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc labels Feb 27, 2025
@steffahn
Copy link
Member

steffahn commented Feb 27, 2025

searched toolchains nightly-2024-07-20 through nightly-2024-08-30


********************************************************************************
Regression in nightly-2024-08-01
********************************************************************************

fetching https://static.rust-lang.org/dist/2024-07-31/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-07-31: 40 B / 40 B [====================================================================] 100.00 % 165.01 KB/s converted 2024-07-31 to f8060d282d42770fadd73905e3eefb85660d3278
fetching https://static.rust-lang.org/dist/2024-08-01/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-08-01: 40 B / 40 B [====================================================================] 100.00 % 249.29 KB/s converted 2024-08-01 to 28a58f2fa7f0c46b8fab8237c02471a915924fe5
looking for regression commit between 2024-07-31 and 2024-08-01
fetching (via remote github) commits from max(f8060d282d42770fadd73905e3eefb85660d3278, 2024-07-29) to 28a58f2fa7f0c46b8fab8237c02471a915924fe5
ending github query because we found starting sha: f8060d282d42770fadd73905e3eefb85660d3278
get_commits_between returning commits, len: 7
  commit[0] 2024-07-30: Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68
  commit[1] 2024-07-30: Auto merge of #128413 - matthiaskrgr:rollup-nrfcvdq, r=matthiaskrgr
  commit[2] 2024-07-31: Auto merge of #128075 - Oneirical:try-your-damnetest, r=jieyouxu
  commit[3] 2024-07-31: Auto merge of #128420 - weihanglo:update-cargo, r=weihanglo
  commit[4] 2024-07-31: Auto merge of #127513 - nikic:llvm-19, r=cuviper
  commit[5] 2024-07-31: Auto merge of #128435 - matthiaskrgr:rollup-l76vu3i, r=matthiaskrgr
  commit[6] 2024-07-31: Auto merge of #126991 - cjgillot:gvn-prof, r=oli-obk
ERROR: no CI builds available between f8060d282d42770fadd73905e3eefb85660d3278 and 28a58f2fa7f0c46b8fab8237c02471a915924fe5 within last 167 days

so this might be

@rustbot label -E-needs-bisection

@rustbot rustbot removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Feb 27, 2025
@nikic
Copy link
Contributor

nikic commented Feb 27, 2025

This sounds like llvm/llvm-project#81689 to me.

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 28, 2025
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants