rust-lang / rust-lang/rust

4000% performance regression with "-C target-cpu=x86-64-v3" and fat LTO

Open
#146,497 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LTO C-optimization I-slow T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The problem:

bench_mat4_transform_point3
                        time:   [18.883 ns 18.986 ns 19.093 ns]
                        change: [+4284.5% +4303.0% +4320.2%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe

I encountered this issue while working on benchmarks from nalgebra crate after recompiling it with RUSTFLAGS="-C target-cpu=native".

Here is the smaller reproducer with more details in README: https://github.com/im-0/rust-fat-lto-perf-degradation (it still uses nalgebra and criterion as dependencies). This reproducer requires codegen-units = 32, but some benchmarks from nalgebra suffer even with just lto = "fat" and default value of codegen-units (which is 16).

I expected to see this happen: no or small performance degradation

Instead, this happened: more than 4000% performance degradation

Meta

rustc --version --verbose:

rustc 1.89.0 (29483883e 2025-08-04) (Fedora 1.89.0-2.fc42)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.8

and

rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked rust-fat-lto-perf-degradation repository and its README, reproducing bench_mat4_transform_point3 with -C target-cpu=x86-64-v3 or native, fat LTO, and the reported codegen-units settings. Compare the nalgebra and criterion benchmark results across configurations and inspect the compiler behavior involved. Done means identifying and correcting the regression without the reported performance loss, with the reproducer or an equivalent regression test passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.