Skip to content
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

Compiler is still slow in rejecting "Invalid left-hand side of assignment" #103411

Closed
jruderman opened this issue Oct 22, 2022 · 1 comment · Fixed by #103415
Closed

Compiler is still slow in rejecting "Invalid left-hand side of assignment" #103411

jruderman opened this issue Oct 22, 2022 · 1 comment · Fixed by #103415
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times.

Comments

@jruderman
Copy link
Contributor

rustc takes 75ms to reject each line of 1 = ();.

Testcase (100 repetitions)

fn main() {
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (dcb376115 2022-10-20)
binary: rustc
commit-hash: dcb376115066d111dbf5f13d5ac2a2dbe8c12add
commit-date: 2022-10-20
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2

Observations

  • This is left over from Exponential compilation time on chained "invalid left-hand side of assignment" #103219. Now it's linear (not exponential), but the constant factor is very high.
  • The slow pass is still item_bodies_checking.
  • Nearly 100% of the time is spent in probe_for_return_type.
  • I flattened this testcase from 1 = 1 = ... = 1; to repeats of 1 = ();. This doesn't affect the speed, but may make the sample tree easier to read.
  • It becomes 5x faster if I add #![no_std]. This strikes me as odd because I wouldn't expect anything in std to make this assignment valid.

@rustbot label +I-compiletime

@jruderman jruderman added the C-bug Category: This is a bug. label Oct 22, 2022
@rustbot rustbot added the I-compiletime Issue: Problems and improvements with respect to compile times. label Oct 22, 2022
@compiler-errors
Copy link
Member

I personally don't think we need to optimize diagnostics code, especially cases grows linearly in time with the number of repetitions -- plenty of other diagnostics do expensive computations in their attempt to suggest help.

@bors bors closed this as completed in 07b5c6b Oct 29, 2022
RalfJung pushed a commit to RalfJung/miri that referenced this issue Oct 30, 2022
…ostic, r=TaKO8Ki

filter candidates in pick probe for diagnostics

Fixes #103411, though also fine with closing this PR if my opinion (rust-lang/rust#103411 (comment)) is shared that this doesn't need to  be fixed.

```
~/rust3$ time rustc +nightly ~/test.rs 2>/dev/null

real    0m4.853s
user    0m4.837s
sys     0m0.016s

~/rust3$ time rustc +rust3 ~/test.rs 2>/dev/null

real    0m0.193s
user    0m0.169s
sys     0m0.024s
```

Also fixes #103427.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants