Very long compilation time on Apple Silicon platform #129713
Description
I have a crate with about 2k files and 600kloc. Most of the code is autogenerated. It compiles in less than 2 minutes with release profile on Ryzen 7950X3D 96GB Linux and 40+ minutes on M1Max 64GB MacOS.
According to -Ztime-passes
the majority of the time is spent in finish_ongoing_codegen
. I can't share the original code, it uses a lot of private deps, but the link to the repro case is below.
Reproduces with rustc 1.78, 1.80, 1.81-nightly, 1.82-nightly.
The code in the repo takes 40+ minutes to compile on Apple Silicon (M1 and M3 tested)
On Linux (quite powerful box, 7950X3D, 96GB RAM) it takes 2 minutes.
This is a distilled down version of the original code, the original is autogenerated from a DSL and thus has such weird structure.
Originally it's a HTTP API service with A LOT of endpoints (621 specifically).
The python script recreates the bug.rs
module and could be used to play with the number of "endpoints". It basically looks like that:
X axis: number of "endpoints"
Y axis: seconds to compile.
If the fields in the struct could be made non-optional the problem goes away.
Chat discussion: https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Major.20slowdown.20on.20aarch64-apple-darwin
Repro case: https://github.com/kika/rust-apple-silicon-bug
Activity