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

Slow probing for missing functions near type errors #103427

Closed
jruderman opened this issue Oct 23, 2022 · 0 comments · Fixed by #103415
Closed

Slow probing for missing functions near type errors #103427

jruderman opened this issue Oct 23, 2022 · 0 comments · 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

This takes over a second to emit each cannot find function error message. Somehow, the time spent for each missing function is linear in the number of type errors in the argument expression. Overall, this creates quadratic compilation time, and with a rather high constant factor.

fn slow() {
    not_found_1({
        not_found_2({
            not_found_3({
                not_found_4({
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                    let _ : u32 = ();
                })
            })
        })
    })
}

fn main() {}

Where it's slow

The item_bodies_checking pass is the slow one. It seems to be spending time in probe_for_return_type, like in #103411.

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

@rustbot label +I-compiletime

@jruderman jruderman added the C-bug Category: This is a bug. label Oct 23, 2022
@rustbot rustbot added the I-compiletime Issue: Problems and improvements with respect to compile times. label Oct 23, 2022
@bors bors closed this as completed in 07b5c6b Oct 29, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
…-on-diagnostic, r=TaKO8Ki

filter candidates in pick probe for diagnostics

Fixes rust-lang#103411, though also fine with closing this PR if my opinion (rust-lang#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 rust-lang#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.

2 participants