-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Huge compilation times after #43546 #43787
Comments
I think I'm hitting the same problem (I haven't actually checked this is caused by the same merge request, but I guess it would be too much coincidence). The compilation times went much higher for one of my crates (tokio-jsonrpc). This is what I get:
The difference between 96s (including all deps) on stable and 25 minutes on nightly is huge (yes, that's release build, but anyway). My other project actually builds the release for over an hour now (https://gitlab.labs.nic.cz/turris/pakon-aggregator). Is there anyway I can do to help with the issue? |
This is very unfortunate. We might have to revert my bugfix PR + Niko's PR if we don't find a solution. |
OR I can try to come up with a solution. Let me see whether I can. |
Turns out that this problem is caused by the projection cache committing to (and caching) closure results while the evaluation cache couldn't. This diff makes rustc fast again: diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs
index c2feb54c4d..16e075a1fc 100644
--- a/src/librustc/traits/select.rs
+++ b/src/librustc/traits/select.rs
@@ -893,7 +893,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// being yet uninferred can create "spurious" EvaluatedToAmbig
// and EvaluatedToOk.
if result.is_stack_dependent() ||
- ((result == EvaluatedToAmbig || result == EvaluatedToOk)
+ (result == EvaluatedToAmbig
&& trait_ref.has_closure_types())
{
return; IIRC I added the condition because otherwise inference guessing can cause trouble (unsoundness and wrong codegen under some conditions). I think I can add Chalk-style "anti-leak" features to type inference, but I'll like to discuss it over with @nikomatsakis and @aturon. I think I'll like to: |
Could I ask for what the status here is? Not that I would want to sound disrespectful or try to push anyone, only that I'm bit confused here ‒ my impression from the comments were the first thing that'd happen was to revert something, but it doesn't seem to be the case. Or does it wait on something? On a discussion, or some code being written? Is there something I might try helping with? |
Either way (ICE or 8min compile time) I am entirely blocked on my project, and apparently it affects other people's code, so maybe some priority (or a workaround) would be appropriate here? 1.20 is coming out soon... |
#43546 was backported so tagging this as a beta regression |
triage: P-high Assigning @arielb1 and myself. We've got to figure this out. |
The issue at gist playground - originally by @Marwes - is not fixed by the closure improvements, but rather requires a different fix. |
I wanted to try the fix, so I compiled that branch and compared the output times. All the numbers are somewhat higher, I split the project into multiple smaller crates since the last time, which added to the total compile time (should that happen?).
So, the fix helps to some extent, but either I compiled the branch in a wrong way (but I'm pretty sure it would take much longer if I didn't enable optimisations, though), or there's still room for improvement. I have no idea what that means for the priority, though. |
Hmm. I tried a debug build as well, for the sake of completeness. And it is odd:
So I probably compiled the compiler in somewhat bad way and it is slower. I'll have to wait for the thing to get merged so I can compare it for real. Or, is it possible I observe a different problem (as it manifests a lot on release builds but not debug ones)? Is there something I can try to check if it is the same problem? |
If what @vorner said is true, that PR doesn't make the issue less important. "insane time" / 2 = "insane time". |
After a projection was processed, its derived subobligations no longer need any processing when encountered, and can be removed. This improves the status of rust-lang#43787. This is actually complementary to rust-lang#43938 - that PR fixes selection caching (and @remram44's example, which "accidentally" worked because of the buggy projection caching) while this PR fixes projection caching
This allows caching closure signatures and kinds in the normal selection and evaluation caches, and fixes the exponential worst-case in @remram44's example, which is a part of rust-lang#43787. This improvement is complenentary to rust-lang#43999 - they fix different cases.
1.20 will soon be stable |
This had already been fixed in 1.20 |
@arielb1 oh should sthis still be open? Or tracked for 1.21 instead? |
Tracked for 1.21 |
clear out projection subobligations after they are processed After a projection was processed, its derived subobligations no longer need any processing when encountered, and can be removed. This improves the status of #43787. This is actually complementary to #43938 - that PR fixes selection caching (and @remram44's example, which "accidentally" worked because of the buggy projection caching) while this PR fixes projection caching. r? @nikomatsakis
This allows caching closure signatures and kinds in the normal selection and evaluation caches, and fixes the exponential worst-case in @remram44's example, which is a part of rust-lang#43787. This improvement is complenentary to rust-lang#43999 - they fix different cases.
[beta] Track closure signatures & kinds in freshened types This allows caching closure signatures and kinds in the normal selection and evaluation caches, and fixes the exponential worst-case in @remram44's example, which is a part of #43787. This improvement is complenentary to #43999 - they fix different cases. This is the pre-generators variation of #43938, cloned for beta.
So my impression is that this is fixed now on all releases. Is that correct? |
I'm still getting somewhat strange results (is nightly compiled in a different way than stable?). The nightly is once again somewhat faster than before, but not as fast as stable.
|
I guess I will attempt some profiles and see if something jumps out. |
Sorry for longer time for reply… and sorry for a bit of a confusion. The first numbers are from tokio_jsonrpc, the later ones are from this project (I actually haven't noticed I switched them): https://gitlab.labs.nic.cz/turris/pakon-aggregator I guess both are affected, maybe I have some unusual coding style (too many iterator/future combinators in a row?), or maybe it's because tokio_jsonrpc is the dependency of the other thing. I can run some tests or profiles, if you like. |
Did something change? It seems to be fixed for me now (on the pakon-aggregator).
(It's a different computer, so the stable is slightly larger than the last results, but that shouldn't matter) |
Sure. @nikomatsakis landed another PR. |
Cool. He shouldn't be that honest not to even mention it, how can I be grateful for it otherwise? :-) |
@vorner great to here there have been improvements! I sort of expeced that, but I feel like when I tested I didn't see them, but maybe I did something wrong in my builds. :/ |
After a projection was processed, its derived subobligations no longer need any processing when encountered, and can be removed. This improves the status of rust-lang#43787. This is actually complementary to rust-lang#43938 - that PR fixes selection caching (and @remram44's example, which "accidentally" worked because of the buggy projection caching) while this PR fixes projection caching
Previous issue: #43132 (comment)
PR: #43546
While the patch fixes the ICE for my code, it makes compilation times unacceptably slow. Furthermore, building a previous version of the code that didn't trigger the ICE got about 20 times slower.
Full reproduction steps using Docker and rustup
The text was updated successfully, but these errors were encountered: