`node` process related to fileWatcher consumes 100% CPU due to latest rust-analyzer
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
From "0.3.1896" and later
rustc version: (eg. output of rustc -V)
rustc 1.72.0 (5680fa18f 2023-08-23)
editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
VSCode w/ rust-analyzer version: 0.3.1896-standalone
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
I am woring on Rust code in Linux machine via Remote Development Extension with VSCode.
(i.e., VSCode is installed on Windows machine but Rust code exists in Linux machine.)
And, I am developing Rust code in Android source code(AOSP).
Because code in AOSP is too HUGE, I am using Multi-root Workspace feature in VSCode.
It means I registered necessary directories for me in VSCode workspace.
repository link (if public, optional): (eg. rust-analyzer)
https://github.com/rust-lang/rust-analyzer
code snippet to reproduce:
// add your code here
n/a
more detailed information of issue:
I can see one node process in Linux machine consumes 100% CPU usage and it never dies even if I closed all VSCode.
This node process is related to fileWatcher and I found that this process is started when I open VSCode workspace which is using rust-analyzer.
Please refer below comment for process information:
I checked VSCode log (w/ verbose log enabled) and I found
- when
rust-analyzeris launched, it registers several directories to fileWatcher. - workspace directories are registered and,
- ALL Android source code directories are also registered to fileWatcher. (as I mentioned, Android source code is really huge)
Also, I found that this issue starts to occur from specific rust-analyzer version.
- ~ v0.3.1885 : issue is not occuring.
- v0.3.1896 ~ : confimed that issue is occuring.
I believe this is related to different behavior of fileWatcher registration.
- ~ v0.3.1885 : ONLY workspace directories are registered.
- v0.3.1896 ~ : workspace directories and other ALL directories in Android source tree are registered.
Please check why this 100% CPU consumption issue is happening at latest version of rust-analyzer (at least fro v0.3.1896) and give me the fix or guide.
Thanks,
[ cpu consumption ]
[ about this process ]
Probably due to https://github.com/rust-analyzer/rust-analyzer/pull/16913 which changed the file watching patterns to be relative ones. That does not change what we instruct the client to watch though, so arguably this sounds like a vscode issue to me then if it used to work prior to this version.
I believe I may also be running into this? - Rust-Analyzer with VS Code has my CPU pegged to ~70% without doing anything else. It's making my battery run out approx 5-10x as fast on my laptop.
Can you try setting "rust-analyzer.files.watcher": "server"? Anyways, this is a vscode issue if its related to the node file watcher, that's not something we are in control of.
I think that might have helped - I set the setting, closed all VS Code instances, and reopened just one instance - CPU usage went down from ~60-70% to ~5-10%. Maybe there was one particular instance which had another problem, but either way it seems like my problems have been solved. Thank you!
I may be running into this as well. However, the mentioned setting does not seem to have any effect on it. Whatever the value, client or server, the behavior is consistent: RA spawns a thread for each of its workers scaling with the number of opened files and it consumes the core it is affected completely at 100%. From the light testing I performed, that went up to eight cores, summing up to around 50% total CPU usage.
It might therefore not be linked to the file watching. When RA is running, VSCode also has one of its threads at 100%. I'm using Rust v1.77.2 and VS v1.89.1-1715060508 with RA v0.3.1975. I only started observing this after updating things today.
It seems I don't have the issue anymore with default configuration and the latest versions of things, VS v1.90.0-1717531825 and RA v0.3.1983. I don't see a mention of such a bugfix in the VS release notes though. The problem could therefore have come from RA.
@ati1230 do you still have your specific issue?
I still can see issue with latest VSCode and RA.
But, as I said, my development environment is very special and complex. (Multi-root Workspace with many directories)
I believe that's why I am facing this issue only in my environment.
Anyway, I am okay now cause I can use latest VSCode and RA with "rust-analyzer.files.watcher": "server" option.
As commented before, "rust-analyzer.files.watcher": "server" setting solves the issue.
I just ran into the same issue with macOS after the extension on VSCode updated.
Changing "rust-analyzer.files.watcher": "server" does nothing.
Reverting to previous version is working:
1992 seems to exhibit the problem. For those looking for a workaround, you can install an older version from vscode itself.
@ospfranco yours is a different issue, this is about the node process spinning, not the rust-analyzer process
I will create a new issue! :)