microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.82k stars 594 forks source link

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

Open dtinth opened 2 years ago

dtinth commented 2 years ago

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
dmichon-msft commented 2 years ago

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