rust-lang / rust-lang/rust-analyzer

`node` process related to fileWatcher consumes 100% CPU due to latest rust-analyzer

Open
#17,133 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-vscode C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

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-analyzer is 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,

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report in VSCode using Remote Development, a multi-root AOSP workspace, and rust-analyzer 0.3.1896 or later; compare against 0.3.1885. Start with the verbose VSCode logs and the fileWatcher registrations made when rust-analyzer launches. Done means the watcher no longer registers all unrelated Android source directories and the persistent 100% CPU process is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
devtools, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.