Skip to content

100% system load on macOS Catalina (too eager incorrect case diagnostic) #6433

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

Closed
neilyoung opened this issue Nov 1, 2020 · 23 comments
Closed
Labels
S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@neilyoung
Copy link

...caused by a process rust-analyzer-mac.

Any idea how to throttle that?

image

@lnicola
Copy link
Member

lnicola commented Nov 1, 2020

Does it happen on a specific project?

@lnicola
Copy link
Member

lnicola commented Nov 1, 2020

You might be able to use Instruments (?) to see what it's doing, but most likely it's chalk going awry on some trait-heavy code. I think there are a couple of open issues on that theme.

@neilyoung
Copy link
Author

It happens while I'm editing a rust file (of a bigger project) in VSCode. Yes, I can check with Instruments. Any special wish what I should examine?

@lnicola
Copy link
Member

lnicola commented Nov 1, 2020

No, I'm not familiar with the app.

@neilyoung
Copy link
Author

Ok, I have now checked with activity monitor. The fan of the system is completely off, if VSCode and the rust script is not on top of the desk, but the fan immediately begins to roar and the load is up to 100% for rust-analyzer-mac, once I just hit "Enter" in the window.

With every editing step I see a "cargo check" running in the lower status line. Making a snapshot of what happens over 2.5 secs finds rust-analyzer-mac having about 20 threads running, most of them hanging in "wait" for a mutex, but at least one is very active with sort of grammar analysis whereas most the time is spend in "ide_db::search::FindUsages:"

Does that make sense?

image

@lnicola
Copy link
Member

lnicola commented Nov 4, 2020

So it looks like an "incorrect case" assist is trying to compute a fix and needs to find all references to a name in order to do that.

@matklad I thought assists were resolved lazily, on request?

With every editing step I see a "cargo check" running in the lower status line.

I never noticed that. Do you have auto-saving enabled?

@matklad
Copy link
Member

matklad commented Nov 4, 2020

Huh, excellent catch! Those are diagnostics, and they are not resolved lazily.

We probably should lazy-ifiy that, cc @popzxc

@lnicola lnicola changed the title 100% system load on macOS Catalina 100% system load on macOS Catalina (too eager incorrect case assist) Nov 4, 2020
@lnicola lnicola changed the title 100% system load on macOS Catalina (too eager incorrect case assist) 100% system load on macOS Catalina (too eager incorrect case diagnostic) Nov 4, 2020
@neilyoung
Copy link
Author

Do you have auto-saving enabled?

Yes, this is enabled.

@popzxc
Copy link
Contributor

popzxc commented Nov 4, 2020

Huh, I'll check what I can do.

@popzxc
Copy link
Contributor

popzxc commented Nov 4, 2020

I think I identified the cause (thanks for the call graph!) and will send a fix today.

@neilyoung
Copy link
Author

Looking forward :) Good luck

@neilyoung
Copy link
Author

OK, fetched and compiled. I need a hint where to deploy the binaries. Using

image

in VSCode. TIA

@lnicola
Copy link
Member

lnicola commented Nov 4, 2020

@neilyoung you have two options:

  1. compile it with cargo xtask install (or install --server) and set rust-analyzer.serverPath to ~/.cargo/bin/rust-analyzer
  2. take the compiled binary and copy it to the extension directory (~/Library/Application\ Support/Code/User/globalStorage/matklad.rust-analyzer)

@popzxc
Copy link
Contributor

popzxc commented Nov 4, 2020

Another option is to compile binary via carbo build --release and set rust-analyzer.serverPath to the $FOLDER_WITH_RA/target/release/rust-analyzer

@neilyoung
Copy link
Author

Another option is to compile binary via carbo build --release and set rust-analyzer.serverPath to the $FOLDER_WITH_RA/target/release/rust-analyzer

I was following this advice and nothing seemed to have changed, even though VSCode reacting on this change. However, a complete restart of VSCode with the new analyzer in the path definitely switched off my fans.

Thanks for the quick fix

@lnicola
Copy link
Member

lnicola commented Nov 4, 2020

Yeah, you have to restart the language server (there's a command for it) or reload the window for it to take effect.

@neilyoung
Copy link
Author

I did of course. In fact this was offered by VSC on detecting that I was tempering the config... Didn't help

@neilyoung
Copy link
Author

Anyway, the fan is silent. You can close this issue

@popzxc
Copy link
Contributor

popzxc commented Nov 4, 2020

Not until PR with the fix is merged, I believe :)

@neilyoung
Copy link
Author

OK, sure. No problem

@neilyoung
Copy link
Author

I noticed that the analyzer annotations are less obtrusive (what is great) now. Is this also something you did in your code?

@csnover
Copy link

csnover commented Nov 28, 2020

Commenting mostly to add a cross-reference to issue #5344, since while they don’t seem to be related, until I actually reviewed my sampling data I wasn’t able to find this ticket due to the title using the term “system load” instead of “CPU”. GH issues doesn’t currently show this issue for searches like “high CPU” or “100% CPU”. Hopefully this helps others to find this ticket when they run into this problem.

A workaround is to add incorrect-ident-case to the rust-analyzer.diagnostics.disabled setting to disable this particular diagnostic.

@flodiebold flodiebold added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Dec 21, 2020
@matklad
Copy link
Member

matklad commented Mar 31, 2021

Closing in favor of #8268

@matklad matklad closed this as completed Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants