vscode: High CPU usage spikes when doing virtually anything in JS/TS files (M2 Mac)

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

  • VS Code Version: 1.75.0
  • OS Version: macOS 13.2

Steps to Reproduce:

  1. Type code in VSCode (with ReactJS and JSX)

Hi, this probably seems really basic but I’ve been having an issue with VSCode 1.75.0 on my M2 MacBook Air running the Apple silicon build on macOS 13.2. I work with React, and do not use the built-in terminal. Settings Sync is thankfully off.

Essentially, everything I do in the editor, things as basic as simply typing a character or commenting/uncommenting a line, cause CPU usage to spike and temperatures to rise. The consequence of this is that VSCode is always on the Using Significant Energy list, and my battery level drops much faster when editing code.

I have disabled all extensions (therefore running the app effectively vanilla, uninstalled and reinstalled VSCode, tried older versions, same issue. This is really annoying and significantly deteriorates battery life so help appreciated.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 20 (2 by maintainers)

Most upvoted comments

@fenvalle @mjbvz @tamuratak: I’ve worked out the exact culprit for this, it is this setting for JavaScript (validation). Disabling it stopped the CPU spikes almost completely; now they are down to a much more expected level. While it isn’t crucial to JS editing, this feature is nice to have on, so any ideas on why it could be causing these CPU spikes and potentially how to make it faster? Sorry to keep bothering you guys but this is something that is really bugging me - thank you so much for your assistance. image

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

@tarasis Can you please open a different issue for your problem

To investigate: Git commands (like checking diff) are causing ts server to rebuild files, maybe there is a chance of this being related to the cause of this issue Could someone check if ts server with cpu usage without git still have spikes in cpu usage? microsoft/TypeScript#52876

Thanks for your comment @fenvalle - as a matter of fact, I just tried copying and pasting some non-dependent sections of my main problematic JS file into an empty new file in an empty workspace (no dir opened, or Git). Then I tried making simple edits (the likes of which would cause big CPU usage spikes in the actual file), and I did not note any major CPU usage (worked as you’d expect).

Therefore, this could be related to Git potentially. Defo will further investigate.

Edit (one of many): on further investigation, just tried another project of mine that is a Node module but has no Git repo. No difference, so maybe it isn’t Git causing the issue. Perhaps it is due to the sheer amount of IntelliSense it wants to process, any ideas on how to improve the performance of this?

Same above. I have followed this guide to identify the culprit https://apple.stackexchange.com/questions/351761/vs-code-code-helper-process-using-more-than-100-cpu-on-macos.

Every time I trace something, force stop some process from the activity monitor and the CPU usage goes down, I disable the extension. However this doesn’t seem to be tied to the extensions themselves as it keeps happening.

Extensions I have disabled so far:

What is common among those processes is they are using the TS language server:

ps aux | grep 13314
user         13314  88.5  3.9 447380960 652064   ??  R    10:35AM  16:14.17 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/y0/x5lk6gms0k3115_pbkvw59n40000gn/T/vscode-typescript501/8cdb3bda8879f1f0889b/tscancellation-fbeb639ede07d133c5f3.tmp* --globalPlugins typescript-styled-plugin --pluginProbeLocations /Users/user/.vscode/extensions/jpoissonnier.vscode-styled-components-1.7.0 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc
user         31118   0.0  0.0 407973536    960 s000  R+    1:25PM   0:00.00 grep 13314

ps aux | grep 13313
user         13313  43.3  1.8 447308560 297696   ??  S    10:35AM   4:03.42 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --serverMode partialSemantic --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName /var/folders/y0/x5lk6gms0k3115_pbkvw59n40000gn/T/vscode-typescript501/8cdb3bda8879f1f0889b/tscancellation-a39097a2837e5934d2e6.tmp* --globalPlugins typescript-styled-plugin --pluginProbeLocations /Users/user/.vscode/extensions/jpoissonnier.vscode-styled-components-1.7.0 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc
user         31218   0.0  0.0 407962688     48 s000  S+    1:25PM   0:00.00 grep 13313

Attached is a recording of the language server infinitely restarting from the status bar: https://user-images.githubusercontent.com/42926334/222640833-e9b68836-878a-4ba8-b469-11dc1a92c790.mp4

I am using an M1 mac and have been experiencing this for more than a year.

@tamuratak @mjbvz Have been further experimenting and it appears the JS/TS Language Features built-in extension is the culprit - disabling it stops the CPU spikes. However, I’d like to have it enabled so are there any settings you know of within it that could improve performance if disabled/enabled? (so far I’ve tried setting typescript.disableAutomaticTypeAcquisition to true, no luck unfortunately).