-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Exponential compile time with recursive opaque type #87450
Comments
@Skepfyr what version of rust are you using? Is this also present on nightly? |
Good question! This repros on the latest nightly ( |
Regression means that it was linear, or exponential, but smaller? |
I didn't check....it looks to still be exponential just much quicker, and with a smaller base (~2 vs ~14):
|
Num calls | Time (s) |
---|---|
15 | 0.68 |
16 | 1.3 |
17 | 2.7 |
18 | 5.6 |
19 | 12 |
20 | 25 |
#65293 looks related |
Hmm, the only thing that looks expensive there is the hashing - I wonder if it's hashing |
#87546 cuts down on time for this testcase and others with invalid recursive opaque types by bailing out early if a recursion is found. This fixes the regression but the check time is still exponential in the recursion:
Not sure if that matters in practice though. |
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. @rustbot label -I-prioritize +P-high |
That's the same as before the regression, right? I definitely think that's a change worth making :) I expect the doubling will have a completely different cause. |
Yes, same ballpark. |
…vidtwco Bail on any found recursion when expanding opaque types Fixes rust-lang#87450. More of a bandaid because it does not fix the exponential complexity of the type folding used for opaque type expansion.
Code
I tried this code:
I expected running
cargo check
to produce an error like:It does, but
cargo check
takes time exponential in the number ofwrap
calls, although doesn't appear to use any extra memory.In
foo
the time take looks like:wraps
sI believe it's also exponential in the number of
wrap
calls inbar
.The reason I had code like this was because I was using nom's parser combinators which results in lots of nested closures. I spotted it because this caused rust-analyzer to hang because cargo clippy hung (it looks like check was the issue), I had to kill clippy to fix it.
Bisection results
I bisected this (with cargo-bisect-rustc) to find the regression in
nightly-2019-10-16
, which contained the following bors commits:@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
The text was updated successfully, but these errors were encountered: