Skip to content

Very long compilation time on Apple Silicon platform #129713

@kika

Description

@kika

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:
image
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

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 28, 2024
added
O-macosOperating system: macOS
O-AArch64Armv8-A or later processors in AArch64 mode
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
on Aug 28, 2024
added
I-compiletimeIssue: Problems and improvements with respect to compile times.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 29, 2024
added
C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing such
on Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-compiletimeIssue: Problems and improvements with respect to compile times.O-AArch64Armv8-A or later processors in AArch64 modeO-macosOperating system: macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kika@saethlin@workingjubilee@rustbot

        Issue actions

          Very long compilation time on Apple Silicon platform · Issue #129713 · rust-lang/rust