Open
Description
Code
I tried this code:
pub fn main() {
let n = 100 as usize;
println!("n: {}", n);
let mut v = vec![0; n];
for _ in 0..100_000_000 {
v.iter_mut().for_each(|x| {
*x = 4;
})
}
}
I expected to see this happen: Performance at least matching previous versions of Rust
Instead, this happened: On my machine, the execution time on nightly is around 2x
as long as on Rust 1.69. The time reported by perf stat
went from 0.35 to 0.67 seconds, and the instruction counts went up from 6.7 billion to 8.9 billion.
Version it worked on
It most recently worked on: 1.69
Version with regression
rustc --version --verbose
:
rustc 1.72.0-nightly (46514218f 2023-06-20)
binary: rustc
commit-hash: 46514218f6f31ad3a1510ecc32af47e9e486c27d
commit-date: 2023-06-20
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5
The regression also affects Rust 1.70, but the performance difference is not as big as on nightly.
Backtrace
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: This is a bug.Issue: Problems and improvements with respect to performance of generated code.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Untriaged performance or correctness regression.