Skip to content

TS Server high cpu usage after yarn install #37653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mjbvz opened this issue Mar 28, 2020 · 8 comments · Fixed by #38560
Closed

TS Server high cpu usage after yarn install #37653

mjbvz opened this issue Mar 28, 2020 · 8 comments · Fixed by #38560
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status. VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Mar 28, 2020

TypeScript Version: 3.9.0-dev.20200316

Search Terms:

  • tsserver
  • yarn install / npm install
  • performance cpu

Repro

  1. In the VS Code code base
  2. Open a ts file under src
  3. Wait for initialization to finish
  4. Then run yarn

Bug
The CPU usage of TS Server remained high for about 10 minutes after doing this. In the TS Server logs, I see a huge block of logged lines that look like:

Info 10105[13:17:2.614] Elapsed:: 0ms DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/strip-ansi :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10106[13:17:2.614] DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/wide-align :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10107[13:17:2.614] Elapsed:: 0ms DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/wide-align :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10108[13:17:2.614] DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/util-deprecate :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10109[13:17:2.614] Elapsed:: 0ms DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/util-deprecate :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10110[13:17:2.614] DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/wrappy :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10111[13:17:2.614] Elapsed:: 0ms DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/wrappy :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10112[13:17:2.614] DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/yallist :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10113[13:17:2.614] Elapsed:: 0ms DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/yallist :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10114[13:17:2.614] DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/strip-json-comments :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10115[13:17:2.614] Elapsed:: 0ms DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/strip-json-comments :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10116[13:17:2.614] DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/tar :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10117[13:17:2.614] Elapsed:: 0ms DirectoryWatcher:: Triggered with /users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/tar :: WatchInfo: /users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project:  WatchType: node_modules for closed script infos in them
Info 10118[13:17:2.614] DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/aproba :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10119[13:17:2.977] Elapsed:: 363ms DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/aproba :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10120[13:17:2.977] DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/are-we-there-yet :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10121[13:17:3.344] Elapsed:: 367ms DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/are-we-there-yet :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10122[13:17:3.344] DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/ansi-regex :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10123[13:17:3.736] Elapsed:: 392ms DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/ansi-regex :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10124[13:17:3.736] DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/abbrev :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10125[13:17:4.107] Elapsed:: 371ms DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/abbrev :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10126[13:17:4.107] DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/code-point-at :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10127[13:17:4.518] Elapsed:: 411ms DirectoryWatcher:: Triggered with /Users/matb/projects/vscode/node_modules/glob-watcher/node_modules/fsevents/node_modules/code-point-at :: WatchInfo: /Users/matb/projects/vscode/node_modules 1 {"watchFile":3} Project: /Users/matb/projects/vscode/src/tsconfig.json WatchType: Failed Lookup Locations
Info 10
@rdewolff
Copy link

I haven't isolated the issue precisely yet, but I have a very similar behaviour. Actually I need to restart VSCode to get back the CPU to low usage.

@mjbvz mjbvz added the VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone label Apr 13, 2020
@mjbvz
Copy link
Contributor Author

mjbvz commented Apr 14, 2020

@RyanCavanaugh This is a priority for the VS Code team but adding the label means it may not show up in your query. Just want to make sure you see it

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Apr 15, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.0 milestone Apr 15, 2020
@sheetalkamat sheetalkamat added Needs Investigation This issue needs a team member to investigate its status. and removed Needs More Info The issue still hasn't been fully clarified labels May 8, 2020
@sheetalkamat
Copy link
Member

Investigating

@sheetalkamat
Copy link
Member

Can you try #38560 (comment) build to see if its better

@mjbvz
Copy link
Contributor Author

mjbvz commented May 27, 2020

Thanks @sheetalkamat! I just tested that branch and confirmed the performance is much, much better on MacOS. I still see a large number of directory watch entries in the logs but all of them now take 0ms.

My test was:

  1. Open the VS Code workspace
  2. Open a ts file
  3. Remove node_modules
  4. Then run yarn

I did not see the prolonged high cpu usage we had previously and the responsiveness was much better after the install

@sheetalkamat
Copy link
Member

Thanks .. there hasn’t been change in what we watch .. the previous change was on how we update on those events .. so this change just tunes it more .. thanks for verifying.. will get PR ready for review

@lehoai
Copy link

lehoai commented Sep 2, 2021

still happen in the latest vscode

@microsoft microsoft locked as resolved and limited conversation to collaborators Sep 2, 2021
@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 2, 2021

@lehoai Please open a new issue with steps to reproduce the problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status. VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants