Skip to content
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

VSCode incredibly slow, 100% CPU usage, coming from electron_node tsserver.js CPU usage #40138

Closed
jfarris587 opened this issue Aug 14, 2020 · 25 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Needs Investigation This issue needs a team member to investigate its status. Needs More Info The issue still hasn't been fully clarified Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@jfarris587
Copy link

  • 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

@jwhousley
Copy link

Yes! VS CODE is awful after the latest update.

@jfarris587
Copy link
Author

Yes! VS CODE is awful after the latest update.

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

@jwhousley
Copy link

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.

@timurmelnikov
Copy link

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.

@mjbvz
Copy link
Contributor

mjbvz commented Aug 15, 2020

If you are not @jfarris587, open a separate issue

@mjbvz
Copy link
Contributor

mjbvz commented Aug 15, 2020

@jfarris587 Can you share the project the causes this?

@jfarris587
Copy link
Author

@mjbvz I cannot share the private project.

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

@mjbvz
Copy link
Contributor

mjbvz commented Aug 17, 2020

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

@jfarris587
Copy link
Author

jfarris587 commented Aug 18, 2020

Downgrading to previous version is also no help

@mjbvz mjbvz transferred this issue from microsoft/vscode Aug 19, 2020
@mjbvz mjbvz removed their assignment Aug 19, 2020
@mjbvz
Copy link
Contributor

mjbvz commented Aug 19, 2020

@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

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Needs Investigation This issue needs a team member to investigate its status. labels Aug 19, 2020
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.1.0 milestone Aug 19, 2020
@DanielRosenwasser
Copy link
Member

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?

@jfarris587
Copy link
Author

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

@davidmcnamee
Copy link

davidmcnamee commented Aug 20, 2020

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

@johandalabacka
Copy link

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

@jfarris587
Copy link
Author

@DanielRosenwasser @mjbvz any progress?

@RyanCavanaugh RyanCavanaugh added Rescheduled This issue was previously scheduled to an earlier milestone and removed Rescheduled This issue was previously scheduled to an earlier milestone labels Aug 31, 2020
@delroh
Copy link

delroh commented Sep 4, 2020

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

@johandalabacka
Copy link

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

@aleksei-berezkin
Copy link

aleksei-berezkin commented Sep 30, 2020

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)

@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Dec 11, 2020
@RyanCavanaugh RyanCavanaugh removed this from the TypeScript 4.1.0 milestone Dec 11, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.2.0 milestone Dec 11, 2020
@alex-shamshurin
Copy link

CocServer for vim also use 100% CPU

@sheetalkamat
Copy link
Member

@aleksei-berezkin do you still see this with typescript@next . If yes can you please share the tsserver log and time around which you see the issue so i can see whats happening in the log and repro it with your code base.
@jfarris587 is this reproing still witg typescript@next. If yes tsserver log would be useful. Thank you.

@evelant
Copy link

evelant commented Jan 25, 2021

There are a number of community packages that seem to commonly cause sluggishness and high CPU usage from TS. For me this is mobx-state-tree. In my project I have consistently very high CPU usage from TS and slow (5-10 second) autocomplete, go-to, and error highlighting. Other common culprits seem to be rxjs, MUI, ramda, xstate, and styled-components. Are those of you having problems using any of these dependencies?

@sheetalkamat sheetalkamat added the Needs More Info The issue still hasn't been fully clarified label Jan 25, 2021
@jfarris587
Copy link
Author

This has been solved.

My tsconfig.json had includes which contained file paths that did not exist in the particular repo, causing an infinite loop of trying to open files in that directory that didn't exist I suppose

@panpansh
Copy link

panpansh commented Dec 28, 2021

if you know what you are doing, just disable all Windows Defender

image

use a firewall gui like GlassWire in order to always know how to manage your outgoing connections by application

image

and adjust your indexing options :
image

then there are the pros of viral signing, the middlemen, and those who think it's pointless. It all depends on how much attention you pay to your system. If in doubt, sandbox, vm.

(oops wrong os)
btw littlesnitch is better than glasswire <3
&&
disable Extensions one by one about vscode

@cassioseffrin
Copy link

I have solve my case, take a look: https://stackoverflow.com/questions/71516186/vs-code-uses-100-cpu-even-if-it-is-closed/72518926#72518926

@eshad
Copy link

eshad commented Aug 27, 2022

Couple of things:

  1. use auto-cpufreq
  2. use multiple workspace during developments (E.g: keep vscode and browser in separate workspace)
  3. use zram
  4. schedule restart system-udevd after 1 min and make it a service

@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Needs Investigation This issue needs a team member to investigate its status. Needs More Info The issue still hasn't been fully clarified Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests