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

TSServer is using 100% CPU on VS Code 1.33 #71886

Closed
dziugasmeskauskas opened this issue Apr 7, 2019 · 44 comments
Closed

TSServer is using 100% CPU on VS Code 1.33 #71886

dziugasmeskauskas opened this issue Apr 7, 2019 · 44 comments
Assignees

Comments

@dziugasmeskauskas
Copy link

Issue Type: Performance Issue

Code helper is using 100% of my cpu. All plugins are disabled and no big files (or large amounts) are present in my workspace.

VS Code version: Code 1.33.0 (0dd516d, 2019-04-04T15:11:32.076Z)
OS version: Darwin x64 18.5.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)
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) 3, 12, 8
Memory (System) 16.00GB (3.61GB free)
Process Argv --disable-extensions .
Screen Reader no
VM 0%
Process Info
CPU %	Mem MB	   PID	Process
   16	    98	  3250	code main
    0	    82	  3257	   gpu-process
    0	   246	  3324	   window (TravelSearch.jsx — bakalauras-ui)
    0	    66	  3348	     extensionHost
  102	   426	  3357	       electron_node tsserver.js 
    0	    66	  3371	         electron_node typingsInstaller.js typesMap.js 
    0	    49	  3350	     watcherService
    0	    98	  3356	   shared-process
    0	    82	  3950	   window (Issue Reporter)
    0	     0	  3964	   /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
Workspace Info
|  Window (TravelSearch.jsx — bakalauras-ui)
|    Folder (bakalauras-ui): 29 files
|      File types: jsx(14) json(3) js(3) lock(1) development(1) log(1)
|                  production(1) ico(1) html(1) md(1)
|      Conf files: package.json(1);
Extensions disabled
@vscodebot vscodebot bot added the new release label Apr 7, 2019
@dziugasmeskauskas
Copy link
Author

This bug is not present in the insiders build.

@RyanCavanaugh
Copy link
Member

Please try deleting ATA cache folder (below) and see if that fixes the problem. We had a large performance regression caused by a combinatorially-explosive file being uploaded to DefinitelyTyped and an unpatched version of it might still be getting loaded. Thanks and please @ me if that doesn't solve your problem!

(Windows)

C:\Users\(your username)\AppData\Local\Microsoft\TypeScript\

(Mac/Linux)

/home/(your username)/.cache/typescript/

@dziugasmeskauskas
Copy link
Author

I checked /home/(your username)/.cache/typescript/, however it was empty. I deleted the TS cache in /Users/(username)/Library/Caches/typescript, the cpu usage has dropped since then.

@RyanCavanaugh
Copy link
Member

@vasilev-alex @b02k5 @kylecorbelli @goodoldneon @Robfz @maxsbelt @ra50 @lewismorris can you try the above fix and let us know the results? Thanks!

@vasilev-alex
Copy link

Didn't work for me. Code helper is still using about 100% CPU

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Apr 8, 2019

@vasilev-alex do you have a project (or subset of a project) that reliably reproduces the problem that you can share with us?

@Robfz
Copy link

Robfz commented Apr 8, 2019

@RyanCavanaugh it did work for me!

@vasilev-alex
Copy link

@RyanCavanaugh Just a create-react-app project with styled components. Check it out here https://github.com/vasilev-alex/react-playground

@kylecorbelli
Copy link

Mine is a TypeScript create-react-app project with styled components. I deleted all of /Users/(username)/Library/Caches/typescript and there wasn't even a /home/(your username)/.cache/typescript/ directory on my machine.

Verdict: the above fix did not work 😭

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Apr 8, 2019

@kylecorbelli the prescribed fix is for JavaScript users. If you are using TypeScript, you'll need to update your project's dependency on @types/styled-components. Apparently there are still issues with TypeScript 3.4 in general, so simply updating the dependency won't fully fix things.

@smancebo
Copy link

smancebo commented Apr 8, 2019

the solution from @RyanCavanaugh works for me in macOS

@andrewcodes404
Copy link

I've had the same problem and narrowed it down to the backticks used in a styled component

const TestStyledComp = styled.div`
   color: pink;
`

I have a basic setup here https://github.com/andrewcodes404/styledcomp-vscode-error/ which works fine until I uncomment the the styled component and then the vs code helper use all my CPU and vscode won't work properly and i get code --status

 102	   426	  3357	       electron_node tsserver.js 

I have used @dziugasmeskauskas solution deleting the cache, /Users/(username)/Library/Caches/typescript it has helped a little but still slowing things down, doesn't feel very stable still gets peaks of electron_node cli.js

@DanielRosenwasser should i be using a different version of typescript?

@TotesOates
Copy link

I got the same issue here. Opening up a javascript file will cause codehelper to jump to 150% to 300% CPU usage. Tried remove the cache folders and resetting VS Code but it's not working.

@RyanCavanaugh
Copy link
Member

We're investigating at microsoft/TypeScript#30819 and pushing a mitigating fix at DefinitelyTyped/DefinitelyTyped#34564

@RyanCavanaugh
Copy link
Member

The mitigation from the DefinitelyTyped PR has been merged - please do another cache clear and see how things are now. Note that after the cache clears, you will see a one-time perf hit during first launch - but after the types are downloading, interactive editing should be snappy again. Sorry again for the regression here.

@meritozh
Copy link

meritozh commented Apr 9, 2019

Also you may need pin typescript to 3.3.4000.

@metrip
Copy link

metrip commented Apr 9, 2019

Performance is still significantly worse than with 1.32.3. The styled-components update and cache clear reduce Code Helper's CPU usage, but do not fix it.

In our project, it takes several seconds for 1.33 to resolve a change from foo: string to foo: strin and back, with 100% CPU use from Code Helper. This would be nearly instantaneous with 1.32.

@RyanCavanaugh
Copy link
Member

@metrip can you share a project that displays this behavior? We're particularly interested in your config file (if any)

@thiagoarmede
Copy link

thiagoarmede commented Apr 9, 2019

Getting same problems as @metrip here, intellisense/typechecking are really slow :(

my config file:

{
"compilerOptions": {
"outDir": "./lib",
"module": "commonjs",
"target": "es6",
"lib": ["es2018", "dom"],
"sourceMap": true,
"jsx": "react",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"baseUrl": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "build", "scripts"]
}

@mrcelo
Copy link

mrcelo commented Apr 9, 2019

This bug is crippling my computer, in a simple gatsbyjs project using styled-components. Deleting /Users/(username)/Library/Caches/typescript and restarting VSCode does not resolve the issue for me. Interestingly, this is also happening on VSCode Insider.

@mjbvz mjbvz mentioned this issue Apr 9, 2019
@steveoon
Copy link

The same bug has happened to me. I'm using styled-components with next.js framework.

@thakursaurabh1998
Copy link

I am using type checking for javascript files and the electron_node tsserver.js process is using more than 100% cpu.

@meritozh
Copy link

@thakursaurabh1998 back to [email protected] or use typescript@next, then test again.

@xiaodoubaoldl
Copy link

change the Terminal render type to dom @ALL solve the problem

@andrewcodes404
Copy link

change the Terminal render type to dom @ALL solve the problem

@xiaodoubaoldl could you explain how i can do that? thanks

@xiaodoubaoldl
Copy link

xiaodoubaoldl commented Apr 10, 2019

setting=>search "terminal renderer type" =>change auto to dom @andrewcodes404

@andrewcodes404
Copy link

If you still see performance problems related to tsserver after following the above instructions, please open a new issue and share information about your general project structure so that we can investigate further.

It's still the same problem wether I use the new insiders or not
https://github.com/andrewcodes404/styledcomp-vscode-error/

@ondrejhudek
Copy link

Hey guys, I have successfully got rid of this problem just by following few steps mentioned here before.

  1. I have updated @types/node package to latest, currently have 11.13.2
  2. I have reinstalled typescript package to specific version 3.3.4000 which was recommended here
  3. In your VSCode use workspace version of typescript
  4. Kill VSCode
  5. Delete /home/(your username)/.cache/typescript/
  6. Run VSCode and all good

Hope this will work for you guys as well.

@elainen
Copy link

elainen commented Apr 10, 2019

I had this issue for a couple days. Upgrading @types/styled-components from 4.1.12 to 4.1.14 and deleting /Users/<username>/Library/Caches/typescript fixed it for me. Thanks!

@gi
Copy link

gi commented Apr 10, 2019

I had the same issue after upgrading to version 1.33, but after letting the program run for a little while, the CPU usage is now back to normal.

@TotesOates
Copy link

Looks like deleting the folder having issues and recloning them from git fixed the issue for me.

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 10, 2019

I'm closing this issue as the original problem @dziugasmeskauskas reported and that many others were also seeing was related to the styled components typings and clearing the caches (or updating the typings if you installed them locally) fixes things. See my comment for details.

Again, if you have followed all the instructions and still see performance issues related to tsserver, please open a new issue on github and we can investigate

@mjbvz mjbvz closed this as completed Apr 10, 2019
@mjbvz mjbvz changed the title Code helper is using 100% CPU TSServer is using 100% CPU on VS Code 1.33 Apr 10, 2019
@andrewcodes404
Copy link

2. 3.3.4000

hi @ondrejhudek, one week and still not working for me can I ask about your solution

I have updated @types/node package to latest, currently have 11.13.2
Is that globally or in your project? how did you do this?

I have reinstalled typescript package to specific version 3.3.4000 which was recommended here
is this global or local I do this $ npm install [email protected] but $ tsc -v still comes back with Version 3.4.3

In your VSCode use workspace version of typescript
Can you explain this further?

Thanks

@andrewcodes404
Copy link

If i create a new react next.js app with styled components it works fine, but in this project https://github.com/andrewcodes404/styledcomp-vscode-error2 everything grinds to a halt. Even when editing the react modules(not styled components) the CPU hits the roof with TSServer, I've followed the instructions, I have moved the project files and fresh install the npm modules but it still persists?

@mjbvz when you say For JavaScript users: clearing the typings cache
do you mean this cache /Users/(username)/Library/Caches/typescript . ?

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 12, 2019

@andrewcodes404 Are you using VS Code 1.33.1? It should clear cache automatically.

If you are still seeing problems, please open a new issue so we can continue investigating

@indransyah
Copy link

I'm using Mac and VS Code 1.33.1, terminal.integrated.rendererType: "dom" already set on my setting from previous versions and it had high CPU usage when idle. Removing those setting solved the high CPU usage.

@jMoulis
Copy link

jMoulis commented Apr 27, 2019

Well I guess the only way for me was to disable "TypeScript and JavaScript Language Features" :-D
I don't know what happened but I never had this pb before on my linux since the last update made today. But on my mac I have this trouble since a month now. And I did not add any extensions

@rdhox
Copy link

rdhox commented May 6, 2019

Same for me on a new MBP 15" 2018. It was the same on my old MBP 15" 2015 (that I changed because of this bug by the way, I was thinking that my MBP was going mad in a middle of a sprint, so didn't have the time to check everything... So technically Microsoft owe me 3000€).

Still not resolve today, "TypeScript and JavaScript" build-in extension make my processus goes + 300%...

@mrcelo
Copy link

mrcelo commented May 17, 2019

Up to this point, I hadn't had any luck resolving the issue for my workspace (gatsby + styled-components) using any of the methods suggested, including deleting /home/(your username)/.cache/typescript/

However, the problem went away after I checked and unchecked Javascript > Implicit Project Config: Check JS in workspace settings after fiddling around. ¯\_(ツ)_/¯

@rdhox
Copy link

rdhox commented May 20, 2019

Up to this point, I hadn't had any luck resolving the issue for my workspace (gatsby + styled-components) using any of the methods suggested, including deleting /home/(your username)/.cache/typescript/

However, the problem went away after I checked and unchecked Javascript > Implicit Project Config: Check JS in workspace settings after fiddling around. ¯_(ツ)_/¯

Seems to work for me too. Before the manipulation, got the processor at + 100% just by putting my cursor on a styled component. After the check/uncheck, no code helper pass above 70%, and go down very quickly.

My bad, still having the processor going crazy...

@dziugasmeskauskas
Copy link
Author

@rdhox Nothing helped me as well. The only solution is to disable the build in extension TypeScript and JavaScript Language Features. You can find it by searching for in the extension menu @builtin TypeScript and JavaScript Language Features

@mountainmoon
Copy link

屏幕快照 2019-05-20 下午11 57 20
@rdhox As mentioned by meritozh, this works for me. Hope this will work for you.

@microsoft microsoft locked as resolved and limited conversation to collaborators May 21, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented May 21, 2019

If you are seeing performance issue, try using latest VS Code insiders build.

Then if you are still seeing issues when using VS Code insiders (with TypeScript 3.5+), please open a new issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests