Skip to content

Regression in compile time when optimizing for size #91809

Open
@crawford

Description

@crawford

After updating to Rust 1.57, I'm seeing a huge increase in compilation time for an embedded project that I'm working on. The code is unfortunately not open source, but I'm hoping I can provide enough information here to work around that. If I've forgotten to include anything or made bad assumptions, please let me know.

I don't have specific numbers for the slowdown because I haven't waiting long enough for the compilation to finish, but I can say that what used to take ~90 seconds for a full build is now taking more than 10 minutes. The project targets thumbv7em-none-eabihf and is optimized for size. Here are the profiles defined in the cargo manifest:

[profile.dev]
panic = "abort"
codegen-units = 1
debug = true
opt-level = "s"
lto = false

[profile.release]
panic = "abort"
codegen-units = 1
debug = true
lto = true
opt-level = "s"

Here's the interesting thing: we have seen no increase in compilation time when building the main binary. It's the tests that are actually exhibiting the behavior. The tests target x86_64-unknown-linux-gnu and are built with cargo test. If I remove opt-level = "s" from the profiles, I'm able to build the tests just as quickly as before.

I bisected the nightlies and determined that this slowdown seems to have been introduced into nightly-2021-10-14; nightly-2021-10-13 and 1.56.1 don't exhibit this behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-mediumMedium priorityS-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions