Open ArmoredPony opened 1 month ago
AFAIK, rust-analyzer doesn't run either rg
or conhost
.
Based on the fact that your project seems to be related to nushell (which does run conhost...) the fact that this occurs during the "building proc macros" step, and the fact that it doesn't happen when the project has already been built, it sounds like this problem is caused by your project:
Your project or one of it's dependencies is using a procedural macro which is spawning all of these processes. To avoid the problem you'd need to find this procedural macro and fix it.
Then shouldn't the same thing happen if I run cargo check
or cargo build
from terminal without opening VSCode?
cargo check --all-targets
rust-analyzer does some RUSTC_WRAPPER
shenanigans that might be breaking depending on what the build scripts are doing here
cargo check --all-targets
I ran this in terminal too, had no problems whatsoever
One thing you could check is whether setting rust-analyzer.cargo.buildScripts.useRustcWrapper
to false
fixes this behavior. Either way it would be good to find which build scripts / proc-macro is spawning these processes to figure out the problematic interaction here
One thing you could check is whether setting
rust-analyzer.cargo.buildScripts.useRustcWrapper
tofalse
fixes this behavior.
Tried that and it didn't help, VSCode crashed after creating 4k processes. It feels that there are less processes created per second with this option disabled, but it is hard to tell since this number always fluctuates and task manager quickly starts lagging.
I'd like to help you find the problematic dependency but I'm not sure how to do that without manually looking through each crate and its sub-dependency.
I also have noticed that if VSCode crashes or even if the system becomes completely frozen and I'm forced to hard-reboot it, upon opening the project, this issue does not reappear. As if the project was built and it is cleanup that went wrong.
I couldn't find any reference to rg
in your dependency tree. Pretty strange.
Have you disabled all other plugins in vscode?
rust-analyzer version: v0.3.2146
rustc version: 1.82.0
editor or extension: VSCode
When a project is opened, VSCode begins to build it, spawns thousands of
conhost.exe
andrg.exe
processes, until it (hopefully) crashes with 'Out Of Memory' error. Sometimes, it takes down some of the other processes with it (it killed task manager on my Windows machine once). Sometimes, it kills X11 server on my Linux machine. Sometimes, it freezes the whole system, forcing me to reboot. I'm not kidding, I saw process counter go higher than 10000. You have to take my word on that because at this point both Windows and Linux usually become unresponsive, but this screenshot from Windows Task Manager demonstrates the issue with 2k processes running. Most of them areconhost.exe
andrg.exe
and their number only goes higher.Here's a project I'm talking about https://github.com/cptpiepmatz/nu-jupyter-kernel. Although, it looks like it can be any project with a big number of dependencies. To reproduce the issue, clone the repo and open the folder in VSCode.
I tried to look at logs in the 'Output' panel in VSCode but either the extension doesn't print anything in it, or VSCode cannot render it before crashing. Activity bar at the bottom of the screen says something about building proc macros.
If a project is built before being opened in VS Code, no crash happens. VSCode still spawns a lot of processes, but their number usually does not go above 150, and after a while those processes are closed and RAM and CPU consumption is back to normal.
This issue manifests under the same conditions on Windows 10 and Linux Mint 22. It also happens to be the same on pre-release version of the extension.
I would love to provide any additional information I can if it helps to solve the issue.