Skip to content

Faster compile times for release builds with small fix #44655

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

Closed
andjo403 opened this issue Sep 17, 2017 · 12 comments · Fixed by #45054
Closed

Faster compile times for release builds with small fix #44655

andjo403 opened this issue Sep 17, 2017 · 12 comments · Fixed by #45054
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

@andjo403
Copy link
Contributor

Was looking at the printout of llvm passes when I noticed that the functions that was inlined everywhere, and due to this was dead code, was optimized more after inlining.

So as a test I added MPM.add(createGlobalDCEPass()); at the line PassManagerBuilder.cpp#L480 and this reduces the compile time of release build in racer by an average of 23%.

I do not know if this is a good place to add this extra pass but maybe someone that knows how llvm works can use this information to speedup the compilation of release builds.

was also wondering how this works in MIR I see that there is an inline pass but I can not find any dead code elimination

@bluss bluss added 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. A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Sep 17, 2017
@andjo403
Copy link
Contributor Author

the stage1 compilation of rustc went from 828.89 to 691.75 secs with this fix on my computer but that is only a 15% improvement

@oyvindln
Copy link
Contributor

15% is pretty significant.

@jonas-schievink
Copy link
Contributor

Wow, great work!

@TimNN TimNN added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Sep 17, 2017
@TimNN
Copy link
Contributor

TimNN commented Sep 17, 2017

@andjo403: That's some nice improvements! If you feel up to it, go ahead an submit a pull request with your suggested changes. That way someone with experience with LLVM is guaranteed to look at the patch and it won't get lost.

@leoyvens
Copy link
Contributor

I believe the PR should be targeted at https://github.com/rust-lang/llvm.

@TimNN
Copy link
Contributor

TimNN commented Sep 17, 2017

@leodasvacas: 👍

@andjo403: If you want to push through this patch the general process works like this:

  • Submit the patch against the currently active branch of rust-lang/llvm (which is rust-llvm-release-4-0-1 at the moment)
  • Wait for it to get reviewed & merged
  • Submit a pull request against rust-lang/rust which updates the src/llvm submodule.

If you have any questions about the process or want someone else to do this, just mention it here or contact me or someone else on one of the Rust IRC channels.

@Mark-Simulacrum
Copy link
Member

cc @arielb1

@nagisa
Copy link
Member

nagisa commented Sep 17, 2017

cc #33299

@cuviper
Copy link
Member

cuviper commented Sep 17, 2017

Ideally, the process should include discussion with upstream LLVM too.

@andjo403
Copy link
Contributor Author

llvm ticket

bors added a commit that referenced this issue Oct 5, 2017
Faster compile times for release builds with llvm fix

Run global optimizations after the inliner to avoid spending time on optimizing dead code.

fixes #44655
@alexcrichton
Copy link
Member

Unfortunately it looks like we were a bit too eager to close this in #45054 :(

@alexcrichton alexcrichton reopened this Oct 7, 2017
@andjo403
Copy link
Contributor Author

From what I have learned from the llvm maintainers I think that we have received the improvement that can be expected. The to good to be true improvements I measured was probably due to less optimizations was possible and resulted in less optimized code.

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-enhancement Category: An issue proposing an enhancement or a PR with one. 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

Successfully merging a pull request may close this issue.

10 participants