Typescript: VSCode incredibly slow, 100% CPU usage, coming from electron_node tsserver.js CPU usage

Created on 14 Aug 2020  ·  18Comments  ·  Source: microsoft/TypeScript




  • VSCode Version: 1.48.0
  • OS Version: iOS Catalina 10.15.5

Steps Attempted to Resolve issue:

  1. Disable all extensions except typescript/javascript features
  2. Install JS and TS Nightly extension as recommended
  3. Downgrading to previous version of VSCode (1.32.0)
  4. Installing latest VSCode Insiders
  5. Increased max memory allowed by typescript server
  6. Check to make sure no extension takes more than 100ms to load

Additional Info

The project is 200k lines and smaller projects do not have the issue. Its primarily related to typescript because if I disable the built-in javascript/typescript features then the tsserver doesn't spin up, so no problem.

  • The hovering types are almost always at "loading..." state.
  • Cmd Clicking into types to see what they are is also insanely slow and practically unusable
  • Autocomplete is incredibly slow, and often nonexistent, even for basic commands like 'clo' for console.logs
  • Red error lines from intellisense are 2-5min lagging behind my actual changes. its like vscode is hung up

If I open the project freshly, find an object, and change a variable to gibberish, then it will take several minutes for VSCode to complain to me with intellisense. Simply saving, and running the app in the browser with auto-reload is faster because chrome will show me compile errors

Below is the result of running ps aux | grep [number]:

jfarris          90151 100.8  1.6  7160436 550880   ??  R     9:30AM   9:16.20 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --max-old-space-size=8072 /Users/jfarris/Documents/amaro-ui/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --enableTelemetry --cancellationPipeName /var/folders/mg/97w2bx6d1fqdkyd9bmyh6sd00000gp/T/vscode-typescript502/31ba41063dba52b8428d/tscancellation-0b463b00b389646856b1.tmp* --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation

jfarris          92342   0.0  0.0  4408572    816 s002  S+    9:40AM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox 90151

Below is the process explorer - notice the tsserver.js using more than 100%. This happens when turning on VSCode > it then slows down to normal number > then i start editing in VSCode and it jumps back up > it stays up for 2-3min AFTER I've stopped editing > then finally slows down. But sometimes it just stays at 100 even 5+ min after I've finished editing

Screen Shot 2020-08-14 at 9 39 47 AM

Below is the CPU usage from the activity monitor

Screen Shot 2020-08-14 at 9 39 23 AM


Does this issue occur when all extensions are disabled?: Yes/No

Bug Performance Needs Investigation

Most helpful comment

Yes! VS CODE is awful after the latest update.

All 18 comments

Yes! VS CODE is awful after the latest update.

Yes! VS CODE is awful after the latest update.

from 1.47 -> 1.48? My problem existed before 1.48.0 as well

Yes! VS CODE is awful after the latest update.

from 1.47 -> 1.48? My problem existed before 1.48.0 as well

I had no issues until this morning. It now takes about 20 seconds for a simple console app to start.

After updating to version 1.48.0, the processor load reaches 100% (https://i.imgur.com/W30f0On.png). Everything worked well in the previous version.

If you are not @jfarris587, open a separate issue

@jfarris587 Can you share the project the causes this?

@mjbvz I cannot share the private project.

Why would I open another issue that is an exact copy of this one

Then please collect the TS Server log:

  1. In the VS Code settings, set "typescript.tsserver.log": "verbose",
  2. Restart VS Code and reproduce the problem
  3. In VS Code, run the TypeScript: Open TS Server log command
  4. This should open a large log file called tsserver.log

    If you can share the log, we will take a look to see if anything stands out

    ⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

Downgrading to previous version is also no help

@sheetalkamat It looks like there are a few long running calls to updateOpen that may explain this:

Info 517  [12:40:1.211] Open files: 
Info 517  [12:40:1.211]     FileName: /Users/jfarris/Documents/amaro-ui/src/pages/DCT/NodeDiagram/NodeHeaderMenu/NodeHeaderMenu.tsx ProjectRootPath: /Users/jfarris/Documents/amaro-ui
Info 517  [12:40:1.211]         Projects: /Users/jfarris/Documents/amaro-ui/tsconfig.json
Perf 517  [12:40:1.211] 2::updateOpen: elapsed time (in milliseconds) 88175.9739

Looks like there's around 1060 files but shouldn't cause an 80-second load time.

@jfarris587 that log looks like 3.9.7 though. Does that mean you're seeing the same issue regardless of the nightly extension?

Looks like there's around 1060 files but shouldn't cause an 80-second load time.

@jfarris587 that log looks like 3.9.7 though. Does that mean you're seeing the same issue regardless of the nightly extension?

Yes, with or without the nightly extension it produces the problem

This happened to me right after I ran yarn add antd @ant-design/icons react-copy-to-clipboard and tsserver.log was filled with messages like this (repeated 50k times before I force stop):

Info 56630[14:32:44.20] Elapsed:: 33ms DirectoryWatcher:: Triggered with /Users/davidmcnamee/dev/aritzia-notifier/node_modules/@ant-design/react-slick/node_modules/lodash/_freeGlobal.js :: WatchInfo: /Users/davidmcnamee/dev/aritzia-notifier/node_modules 1 undefined Project: /Users/davidmcnamee/dev/aritzia-notifier/chrome/tsconfig.json WatchType: Failed Lookup Locations
Info 56631[14:32:44.20] DirectoryWatcher:: Triggered with /Users/davidmcnamee/dev/aritzia-notifier/node_modules/@ant-design/react-slick/node_modules/lodash/_deburrLetter.js :: WatchInfo: /Users/davidmcnamee/dev/aritzia-notifier/node_modules 1 undefined Project: /Users/davidmcnamee/dev/aritzia-notifier/chrome/tsconfig.json WatchType: Failed Lookup Locations
Info 56632[14:32:44.60] Elapsed:: 40ms DirectoryWatcher:: Triggered with /Users/davidmcnamee/dev/aritzia-notifier/node_modules/@ant-design/react-slick/node_modules/lodash/_deburrLetter.js :: WatchInfo: /Users/davidmcnamee/dev/aritzia-notifier/node_modules 1 undefined Project: /Users/davidmcnamee/dev/aritzia-notifier/chrome/tsconfig.json WatchType: Failed Lookup Locations

Installed 1.47 (https://code.visualstudio.com/updates/v1_47) and problem went away.

Running
VSCode Version: 1.48.1 (before downgrade)
OS Version: iOS Catalina 10.15.6

@DanielRosenwasser @mjbvz any progress?

I guess my issue may be related, in the process explorer I can see multiple electron_node package.js processes consuming a lot of CPU and vscode runs ultra slow. It happens only when I am typing and so far on a specific javascript project. Should I open a new issue or post log here?

Version: 1.48.2 (user setup)
Commit: a0479759d6e9ea56afa657e454193f72aef85bd0
Date: 2020-08-25T10:13:11.295Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041

I have used the newest version for the whole day:

Version: 1.49.0
Commit: e790b931385d72cf5669fcefc51cdf65990efa5d
Date: 2020-09-10T17:39:53.251Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0

And I haven't noticed the behaviour yet

Hi there. I can share a file on which issue reproduces stable for me: https://github.com/aleksei-berezkin/fluent-streams/blob/master/src/impl/stream.test.ts

Observed behavior: whenever I edit a file in VSCode, a process running tsserver.js starts a work consuming 100% of CPU, and it takes about 12–14 seconds on my machine to complete. (MacBook Pro with 16 GB RAM and i7). This reproduces on each edit.

I made a small research and found out that it's likely type inference triggered by getSemanticDiagnostics. I can take additional profile or dump if you wish.

VS Code “about” output:

Version: 1.49.2
Commit: e5e9e69aed6e1984f7499b7af85b3d05f9a6883a
Date: 2020-09-24T16:23:52.277Z (5 days ago)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Roam-Cooper picture Roam-Cooper  ·  3Comments

MartynasZilinskas picture MartynasZilinskas  ·  3Comments

fwanicka picture fwanicka  ·  3Comments

manekinekko picture manekinekko  ·  3Comments

uber5001 picture uber5001  ·  3Comments