codegen-units=1 + LTO causes 3-5% performance regression for sequential code
Open
Nobody has claimed this yet.
A-LLVM
A-LTO
C-optimization
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
I tried this code:
The bug trigger:
Line 374: BigUint variable
↓
Line 377: Loop (1M+ iterations)
↓
Line 383: Arithmetic operation
↓
With codegen-units=1 + LTO
↓
LLVM over-inlines Line 383
↓
Register pressure (16 GPRs on x86_64)
↓
Stack spilling
↓
-5% performance regression
I expected to see this happen: "may improve performance"
Instead, this happened: 3-5% slower
uutils/coreutils#9161:
- seq_integers: -5.06% (26.1ms → 27.5ms)
- seq_with_step: -4.98% (13.3ms → 14.0ms)
- expand_custom_tabstops: -2.73% (36.6ms → 37.6ms)
- cut_fields_custom_delim: +32.29% (40.7ms → 30.8ms)
- cut_fields_tab: +26.13% (34.1ms → 27.0ms)
- Overall: -10.02% (22 improvements, 10 regressions)
Related
- rust-lang/rust#93321
- rust-lang/rust#48371
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/uu/seq/src/seq.rs lines 374-385 and reproduce the reported benchmarks from uutils/coreutils#9161 using codegen-units=1 with LTO enabled. Compare the affected sequential cases and generated performance results against the reported baseline; done means the regression is explained and a verified resolution or compiler-side next step is documented.
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