Vscode: Overall perf. issue with TypeScript(JS)

Created on 15 Apr 2019  ·  29Comments  ·  Source: microsoft/vscode

Issue Type: Performance Issue

  • When did this performance issue happen?
    After updating to 1.33 (everything is still fine at 1.32)
  • Does it occur on startup or after a specific series of actions?
    It happens when you need to use TypeScript Intellisense.

PS: I didn't experience this in a TypeScript Project, My Project is a ES6 JS Project.

It really got messy when you try to cmd/ctrl+click to anything.

PS2: removing TypeScript cache helps a bit but after an hour it became slow again

VS Code version: Code 1.33.1 (51b0b28134d51361cf996d2f0a1c698247aeabd8, 2019-04-11T08:22:55.268Z)
OS version: Darwin x64 18.5.0


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz (8 x 2000)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled|
|Load (avg)|4, 3, 2|
|Memory (System)|8.00GB (0.09GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|


Process Info

CPU %   Mem MB     PID  Process
   22       90   44270  code main
    6       49   44271     gpu-process
    5      262   44272     window (glocalzone (Workspace))
    0      156   44421       extensionHost
    0      492   44427         electron_node tsserver.js 
    0       74   44437           electron_node typingsInstaller.js typesMap.js 
    0      467   44428         electron_node language-server-stdio.js 
    0       57   44430         electron_node server.js 
    0       98   44431         electron_node eslintServer.js 
    0       33   44438         /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/jsonServerMain --node-ipc --clientProcessId=44421
    1       49   44460         electron_node server.js 
    0      147   44511         extensionHost
    0      123   44521         extensionHost
    0      139   44523         extensionHost
    0       25   44422       watcherService
    0       41   44426       searchService
    0       74   44423     shared-process
    0       74   44546     window (Issue Reporter)
    0        0   44551     /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=



Workspace Info

|  Window (glocalzone (Workspace))
|    Folder (gz-api): 98 files
|      File types: js(66) graphql(11) json(9) DS_Store(4) yml(1) graphqlrc(1)
|                  babelrc(1) sh(1) gitignore(1) lock(1)
|      Conf files: package.json(1) webpack.config.js(1)
|    Folder (gz-app): more than 24620 files
|      File types: hpp(7604) flat(2181) h(1749) pcm(835) timestamp(790)
|                  png(611) jar(579) hmap(240) xml(202) m(194)
|      Conf files: package.json(1) settings.json(1);


Extensions (21)

Extension|Author (truncated)|Version
---|---|---
sublime-cmd-shift-d|and|1.2.2
vscode-eslint|dba|1.8.2
es7-react-js-snippets|dsz|2.2.1
gitlens|eam|9.6.0
vscode-npm-script|eg2|0.3.5
prettier-vscode|esb|1.8.1
path-autocomplete|ion|1.13.2
styled-components-snippets|jon|0.1.7
vscode-styled-components|jpo|0.0.26
vscode-wrap-console-log|mid|1.7.2
vscode-versionlens|pfl|0.22.0
macos-dark-mode-theme|phi|0.2.7
vscode-graphql|Pri|0.1.7
subtle-brackets|raf|3.0.0
code-settings-sync|Sha|3.2.8
stylelint|shi|0.48.0
mdx|sil|0.1.0
indenticator|Sir|0.6.0
ignore-gitignore|stu|1.0.1
selectline-statusbar|tom|0.0.2
vscode-import-cost|wix|2.12.0

(1 theme extensions excluded)


*duplicate freeze-slow-crash-leak needs more info typescript upstream

Most helpful comment

Closing. A spike in cpu usage is expected on first open

All 29 comments

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

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

Yes, on the insider assembly, in my TypeScript project (TSX) this is repeated.

I forgot to mention this but beside the slowness, intellisense got not so intelligence :) (go to wrong root definitions or just stuck at same definition)

@berkaey Did you test on insiders? Also, do you have @types/styled-components in your node_modules?

No I didn't. and No both workspace folders doesn't have @types/styled-components in node_modules.

btw, @mjbvz, you mean insiders version? if it so, how can i download it ?

https://code.visualstudio.com/insiders/. Test with all extensions disabled

Hey @mjbvz, I tested for 10 mins without any extensions, I guess it is much better than 1.33 but I think still has slower navigation on some case and sometimes it goes to import definition first sometimes it just goes to file itself.

@mjbvz, after a full-day test on insider(with extensions) issue still stands. A bit more fast than 1.33 but lags behind 1.32

@berkaey So this didn't happen when you disabled all extensions?

Also, can you share your project?

I tested without extensions only 10-20 min. 'cause I'm much slower without extensions :). Do you mean workspace file?

@mjbvz We're using @types/styled-components. What's the deal with them?

@berkaey If this only happens when extensions are enabled, then one of your extensions is causing this.

If you can share your project (as a github repo) then we can investigate this better

@mjbvz it is happening without extensions also, (but bit better from 1.33) I'm using same extensions on 1.32 and works flawlessly. (I'm actually had to use 1.32 otherwise all of my MacBook Pro fans just hit the ceil :) too much cpu usage I guess)

I do have styled-components and it happens with me also. Here's a list of possibly heavy libraries I am using

  1. React/React DOM
  2. Apollo Client with react-apollo.
  3. Styled components.
  4. Ant design.

I am using the following version of vscode

$ code --version
1.33.1
51b0b28134d51361cf996d2f0a1c698247aeabd8
x64

I think it is slow mostly on tsx files.

@berkaey Can you try changing your workspace to use [email protected] by following these instructions. If using the older typescript works in current VS Code builds, then try switching to the current nightly build of typescript by installing typescript@next to see if the issue has been resolved

@mjbvz I'm not using typescript, no tsx files in my workspace (but as you now most of the node_modules libs are typed like styled-components etc.)

Typescript powers our javascript intellisense. Try those steps

@mjbvz Do you think it is happening because of this issue in typescript itself?

I investigated because it was not only vscode which was slow, rather fork-ts-checker-webpack-plugin results too. So I did some benchmarking and

For typescript version 3.4.5 with @types/[email protected]

yarn typecheck  11.16s user 0.56s system 154% cpu 7.611 total

For typescript version 3.5.0-dev.20190502 with @types/[email protected]

yarn typecheck  8.66s user 0.53s system 168% cpu 5.452 total

Overall vscode ts intellisense is much faster now. Also fork-ts-checker plugin performs better.

I'm also getting this, not using styled-components. At one point I had narrowed it down to [email protected], but upgrading to their new types in the 9 beta and it's still slow.

Also for typescript 3.3.4000 with @types/[email protected]

yarn typecheck  6.79s user 0.39s system 171% cpu 4.180 total

So think switching to typescript 3.3.4000 until the problem in upstream is solved is a viable solution for now?

Sounds like this could be https://github.com/microsoft/TypeScript/issues/31341

To check this, can you please try upgrading your workspace to use the next typescript@next that is published (3.5.0-dev.20190513+) by following these instructions

I tried with typescript@rc and the performance improvement is significant and things are back to normal. So with the release of [email protected] it should be resolved.

Here are more details https://devblogs.microsoft.com/typescript/announcing-typescript-3-5-rc/

@berkaey Can you please confirm by testing using the latest VS Code insiders build, which includes TS 3.5-rc

One weird thing I still see is the compiler is slow to output the success
message when you fix the last error. So if you have an error, and you fix
it, it sits at “compiling...” for 6 seconds or so. In reality, it actually
outputs the file before that, but it seems the message just gets held up
for a while.

@mjbvz I was also experiencing slowness in 1.34.0 and I just tried 1.35-insider with all 50ish extensions and it's much faster 🔥 Thanks!

@mjbvz let me check the 1.35-insider

After a quick test, I would say it is more responsive but still lags when I first open a file and cmd+click on an import, (I'm not sure but) when I open insider fans immediately kicks in for a period of time (this could be reason for first issue). After the fans got cooled, smooth as 1.32. 👍

Closing. A spike in cpu usage is expected on first open

Was this page helpful?
0 / 5 - 0 ratings