-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Continuous high CPU usage of rust-analyzer-mac triggered by something in vscode. #5344
Comments
It is busy in chalk. What project is this on? |
Can some user based action be taken to quit this "busy in chalk" loop? |
Quoting @flodiebold (#4800 (comment))
|
It says "Error: Invalid flags" when I run "path_to/rust-analyzer-mac" analysis-stats from the project folder. The only option that works for me is "path_to/rust-analyzer-mac" analysis-stats -h. I tried a few others like -v, still "Error: Invalid flags". |
The command is |
Thank you! When I run
On different runs it comes to this function differently, but when it comes to it, it is stuck. Though when I run it only for this function like you suggested:
It is stuck in:
And no further output is provided. Am I missing something again? Sorry for being a noob. I waited for a few minutes and several times to be sure that it is stuck. What could be my next steps? The function it is stuck in is very short:
|
I'll experiment more, but if I simply remove line with:
Then Thank you a lot for the pointers! If I can help in any way to find where the culprit is, please let me know. |
CC #4186, although it's not necessarily the same issue. By the way, weren't we using fuel for the chalk queries? |
If I rewrite the method in the following way:
To avoid usage of:
Then And yes, rust-analyzer-mac takes longer to chew everything at the start of vscode. But this issue seems to be a "stuck completely" case. |
Hello! Randomly picked an older version - 2020-06-15 release. Then everything works correctly. Currently I don't have time to experiment with other versions. |
Running into this on Linux with version 0.2.240, similarly also using Diesel. Metadata from rust-analyzer gets extremely slow or non-existent, and then hangs almost completely on format on save. Similarly this was working in some previous version (likely ~1 month ago? haven't tried to use on this project in recent weeks). Running the analysis stats command from above gives a similar state where it gets stuck on a particular method which is using similar methods as reported above (
Running with
Attached a 'full' log: ra-debug.txt (truncated after a reasonable amount of repetition) The method in question has a call amounting to: use schema::organisations::{self, dsl as organisation};
fn clear_subscription_sync(conn: &Conn, account_id: Uuid) -> DbResult<()> {
diesel::update(organisations::table)
.filter(organisation::account_id.eq(account_id))
.set(organisation::user_limit.eq(None::<i32>))
.execute(conn)?;
...
} Stubbing out the EDIT: I've created a basic reproduction at https://github.com/c-spencer/ra-diesel-slowness. This seems to just be slowness with Diesel, so might be the same root cause as #4186? A single Making simple changes seems to be quick once it's completed, until certain changes, e.g. removing the semi-colon is okay, but commenting out the |
Running the above reproduction resulted in a lot (many thousands) of these:
That's 182 impls for 10 Looking at
|
These unrestricted searches happen because the self type is an associated type projection, and Chalk doesn't first normalize it. This should get fixed by the syntactic equality work, which sadly seems a bit stalled... |
I tested version 08-31, 08-24, 07-06 and 06-22, they all get stuck on some diesel method. So maybe currently 06-15 is the latest working version for diesel project? |
@staninprague did this get better? |
For me, certainly. I'm still avoiding use of the diesel code construct that caused the issue, but issues when diesel schema regeneration and subsequent updates to diesel related code were causing 100% and long CPU spikes - they are not present for me anymore. Huge thanks to rust-analyzer team members! |
I was asking because the syntactic equality changes that @flodiebold mentioned have landed in chalk. Anyone else, please file different issues, preferably with code that reproduced the problem. |
Thank you for the great tooling for rust!
I'm still trying to find out what triggers the high CPU usage of rust-analyzer-mac (99.9%). When it happens, only closing vscode helps. After it happens the performance of code-editing degrades and "Saving/formatting" popup shows up for some period of time when a file is (auto) saved.
My current gut feeling is that it happens when new files are added to the workspace, but I'm not sure at all.
Here is the backtrace:
(lldb > bt all)
Will be happy to help to dig deeper, but would need more hints.
The text was updated successfully, but these errors were encountered: