rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95.12k stars 12.27k forks source link

MIR_borrow_checking and MIR_effect_checking are very slow #126440

Open programmerjake opened 1 month ago

programmerjake commented 1 month ago

I tried this code:

https://git.libre-chip.org/libre-chip/fayalite/src/commit/25aa90ec603acdc49a984588e75ba62d7f16b5c4

I expected to see this happen: compile in a reasonably short time

Instead, this happened: running cargo +nightly rustc -p fayalite -- -Z time-passes gives small times for everything except:

time:  25.136; rss:  396MB ->  782MB ( +386MB)  MIR_borrow_checking
time:  22.335; rss:  782MB ->  973MB ( +191MB)  MIR_effect_checking

I'm running on a Ryzen 9 7950X so this isn't just a slow cpu.

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (8337ba918 2024-06-12)
binary: rustc
commit-hash: 8337ba9189de188e2ed417018af2bf17a57d51ac
commit-date: 2024-06-12
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

compilation is also quite slow on 1.79.0 stable, using RUSTC_BOOTSTRAP=1 cargo rustc -p fayalite -- -Z time-passes:

time:  24.300; rss:  389MB ->  768MB ( +379MB)  MIR_borrow_checking
time:  21.751; rss:  768MB ->  958MB ( +191MB)  MIR_effect_checking
veera-sivarajan commented 1 month ago

@rustbot label -needs-triage +I-slow +A-mir +A-borrow-checker +T-compiler

oli-obk commented 1 month ago

can you simplify this to a single crate that reproduces your issue? then we can run rustc-perf on it and see which queries are actually at fault, since -Ztime-passes is very coarse in its grouping and can include a lot of trait solving and const eval time