rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] Putting `pnpm-store` inside the project folder causes high CPU usage when a Rush project is opened in VS Code

Open dtinth opened this issue 2 years ago • 1 comments

Summary

I noticed that my CPU usage is unusually high whenever I open a Rush project inside VS Code without doing anything.

image

Repro steps

  1. Create a Rush project.
  2. Install ~180 dependencies in it (this is the number of dependencies we have in our project).
  3. Open a Rush project in VS Code.

Expected result: CPU usage shouldn’t significantly increase (e.g. consistently above 100%).

Actual result: High CPU usage, CPU temperature rises.

Details

This is caused by VS Code’s file watcher trying to watch files in common/temp/pnpm-store. Unlike node_modules, VS Code does not exclude this path by default, and thus attempts to watch every single file. In our project, this causes 79,000+ files to be watched, resulting in high CPU usage.

image

By adding this to .vscode/settings.json, the problem is resolved.

{
  "files.watcherExclude": {
    "**/pnpm-store/**": true
  }
}

image

Maybe rush init should add the above configuration when generating a new project.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.63.1
rushVersion from rush.json? 5.63.1
useWorkspaces from rush.json? false
Operating system? Mac
Would you consider contributing a PR? No
Node.js version (node -v)? v16.15.0

dtinth avatar Jun 08 '22 06:06 dtinth

Ideally all of common/temp should probably be ignored by the vscode watcher

dmichon-msft avatar Jun 08 '22 22:06 dmichon-msft