Skip to content

Long compile times due to initialization of large struct #52960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fintelia opened this issue Aug 1, 2018 · 4 comments
Open

Long compile times due to initialization of large struct #52960

fintelia opened this issue Aug 1, 2018 · 4 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fintelia
Copy link
Contributor

fintelia commented Aug 1, 2018

I tried fixing AltF02/x11-rs#90 with this patch that directly instantiates some (very) large structs via a macro. Unfortunately this change caused compile times to drastically increase. Before a build took only a few seconds, but now a debug build takes 40+ seconds and my attempt to do a release build has been going for 30 minutes over an hour.

~/git/x11-rs/x11-dl$ cargo rustc -- -Z time-passes

~/git/x11-rs/x11-dl$ cargo rustc --release -- -Z time-passes (incomplete log output, killed after producing no further output for an hour.)

Meta

rustc --version --verbose:

rustc 1.29.0-nightly (e94df4acb 2018-07-31)
binary: rustc
commit-hash: e94df4acb4c3f42fdc224a7164b63a99240add1e
commit-date: 2018-07-31
host: x86_64-unknown-linux-gnu
release: 1.29.0-nightly
LLVM version: 7.0
@estebank estebank added the I-slow Issue: Problems and improvements with respect to performance of generated code. label Aug 1, 2018
@ishitatsuyuki ishitatsuyuki added I-compiletime Issue: Problems and improvements with respect to compile times. and removed I-slow Issue: Problems and improvements with respect to performance of generated code. labels Aug 2, 2018
@ishitatsuyuki
Copy link
Contributor

From a quick glance of time-passes... It seems that you're generating quite a big amount of code? I'm not good on macros, but please check if you can generate less.

@fintelia
Copy link
Contributor Author

fintelia commented Aug 2, 2018

Yes, the macros do generate a lot of code, but it isn't that much code. Cargo expand produces under 50k lines of code, and none of it looks all that complex.

The issue seems to be related to having a large number of control flow paths through the function. If I change the try! to an unwrap() compile time falls to under 10 seconds.

@carado
Copy link

carado commented Aug 3, 2018

The compilation might not be just long, it might be running in an infinite loop or at least something exponential.
I tried compiling my project with the original x11-dl replaced with the patched version mentioned above and letting it compile overnight (~8 hours) and x11-dl wasn't done compiling when I woke up.
The attempt was a compilation in debug mode, with the following options:

[profile.dev]
debug = false
opt-level = 2

@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 17, 2018
@ishitatsuyuki
Copy link
Contributor

ishitatsuyuki commented Nov 5, 2018

Marking as LLVM since opt-level matters here and that is often caused by conflicting LLVM optimizations.

@jonas-schievink jonas-schievink added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. labels Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants