Skip to content

TS Server high cpu usage after yarn install #37653

Description

@mjbvz

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

Activity

  1. rdewolff commented on Mar 28, 2020

    @rdewolff

    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.

  2. mjbvz commented on Apr 14, 2020

    @mjbvz
    Author

    Ryan Cavanaugh (@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

  3. added
    Needs InvestigationThis issue needs a team member to investigate its status.
    and removed
    Needs More InfoThe issue still hasn't been fully clarified
    on May 8, 2020
  4. sheetalkamat commented on May 8, 2020

    @sheetalkamat
    Member

    Investigating

  5. sheetalkamat commented on May 14, 2020

    @sheetalkamat
    Member

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

  6. mjbvz commented on May 27, 2020

    @mjbvz
    Author

    Thanks Sheetal Nandi (@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

  7. sheetalkamat commented on May 28, 2020

    @sheetalkamat
    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

  8. lehoai commented on Sep 2, 2021

    @lehoai

    still happen in the latest vscode

  9. locked as resolved and limited conversation to collaborators on Sep 2, 2021
  10. mjbvz commented on Sep 2, 2021

    @mjbvz
    Author

    Le Hoai (@lehoai) Please open a new issue with steps to reproduce the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.VS Code PriorityCritical issues that VS Code needs fixed in the current TypeScript milestone

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions