-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Single file takes 30 minutes to compile at opt-level=3, regression from <1 sec #66617
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
Comments
Labeling as a regression because 🤣 something is going on:
|
I got bored after 40 seconds (I am not a patient man) -- this reproduces at |
On rustc 1.39.0 I see it hangs when running following command : however |
-Ztime-passes is showing:
It hasn't completed yet. I'm also running it under |
Summary: Today in "sacrificing readability / safety due to Rust inefficiencies": I believe some of our compile times are due to (less severe than in example there) version of this bug: rust-lang/rust#66617 Adding box in a key place happens to circumvent it. Reviewed By: shiqicao Differential Revision: D18772104 fbshipit-source-id: a94271b208894aecd9bb8ee1f35110b3c0b09961
at nightly (rustc 1.43.0-nightly (8aa9d20 2020-02-21)) around 2sec |
Marking needstest to add a test to https://github.com/rust-lang-nursery/rustc-perf/ |
Failed to reproduce the fix at 8aa9d20 2020-02-21. Some attempts that I've tried:
It hasn't completed but I have waited for about 2 mins. Here's a part of a perf report (I re-ran it on a linux machine):
The newest master seems to have the same issue. I doubt it was fixed. |
Assigning |
Just in case, wanted to point out that this is still an issue using |
I got some time to make progress on this today. Here's what's up: Some observations:
Progress:
===-------------------------------------------------------------------------===
... Pass execution timing report ...
===-------------------------------------------------------------------------===
Total Execution Time: 99.8300 seconds (99.9532 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
98.6132 ( 98.9%) 0.0245 ( 34.9%) 98.6378 ( 98.8%) 98.7605 ( 98.8%) Function Integration/Inlining
0.1416 ( 0.1%) 0.0046 ( 6.5%) 0.1462 ( 0.1%) 0.1463 ( 0.1%) Combine redundant instructions #2
0.0660 ( 0.1%) 0.0021 ( 3.0%) 0.0681 ( 0.1%) 0.0682 ( 0.1%) Global Value Numbering
0.0576 ( 0.1%) 0.0020 ( 2.9%) 0.0596 ( 0.1%) 0.0596 ( 0.1%) Combine redundant instructions #5
0.0580 ( 0.1%) 0.0016 ( 2.3%) 0.0596 ( 0.1%) 0.0596 ( 0.1%) Combine redundant instructions #3
0.0577 ( 0.1%) 0.0013 ( 1.8%) 0.0590 ( 0.1%) 0.0589 ( 0.1%) Combine redundant instructions #4
0.0483 ( 0.0%) 0.0011 ( 1.6%) 0.0494 ( 0.0%) 0.0494 ( 0.0%) Jump Threading
0.0428 ( 0.0%) 0.0013 ( 1.8%) 0.0441 ( 0.0%) 0.0441 ( 0.0%) Early CSE w/ MemorySSA
0.0398 ( 0.0%) 0.0010 ( 1.4%) 0.0408 ( 0.0%) 0.0408 ( 0.0%) Memory SSA
... I will take a basic look in the function integration/inlining pass later this week with profiling tools and then hand over to my company's LLVM team if needed. |
Looks like all the time is spent inside |
The behavior looks exactly cubic in the number of enum variants as measured by |
Update: The cubic behavior is a legacy pass manager limitation which is a consequence of not having call site's BFI (block frequency) in the legacy inliner. This is a known advantage for inlining with the new pass manager (#74705) vs legacyPM. Here is the place legacy inliner is lacking BFI under legacyPM (note nullptr for GetBFI): At this point we are going to investigate transitioning our affected codebase to newPM. For anyone needing to work around this on legacyPM, one effective legacyPM workaround we found is running |
for this specific case where a lot of vec's is used in the enums I was able to get the times down by adding inline to RawVec::ptr this was one of the two functions that was defined in cgu0 but used in cgu1 and when inline was added it is defined in cgu1 also. I do not understand why the llvm inline pass time is affected by if the function is defined or declared in one cgu but will try to look in to it some more tomorrow. Is a PR with with the inline hint something to do? even as it do not solve the complete problem a lot of functions is marked with inline in RawVec but not this one liner function. |
mark raw_vec::ptr with inline when a lot of vectors is used in a enum as in the example in rust-lang#66617 if this function is not inlined and multiple cgus is used this results in huge compile times. with this fix the compile time is 6s from minutes for the example in rust-lang#66617. I did not have the patience to wait for it to compile for more then 3 min.
Can't reproduce in current stable ( |
Thank you, @ljedrz and everyone else who has gone to the effort of reproducing or investigating this bug. Considering the current status and dtolnay tracing it directly to the pass manager,it looks like we can close this now. |
Put this in your main.rs file: https://gist.github.com/dabek/3474504ab3dae4d264b78504a4d2ee21
Run:
See it take half an hour (at least it did for me the only time I had the patience to wait for it).
The text was updated successfully, but these errors were encountered: