vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

High CPU usage by vscode-server/typescript

Open jaredp opened this issue 4 years ago • 26 comments

Screen Shot 2020-07-05 at 4 59 25 PM

As top reports, VSCode server is using more than 80% of the CPU on my devserver, leaving me with little CPU to run useful commands. It's a free tier t2.micro ec2, making this doubly bad as I'm long-term penalized for any usage over 20%.

The cmd for pids with highest CPU usage, 10553 and 10760 respectively, are reported by /proc/*/cmdline as

/home/ec2-user/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/node--max-old-space-size=3072/home/ec2-user/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/extensions/node_modules/typescript/lib/tsserver.js--useInferredProjectPerProjectRoot--enableTelemetry--cancellationPipeName/tmp/vscode-typescript1000/259048e745e4b6b760a9/tscancellation-389a5bb0a343f462a86f.tmp*--globalPluginstypescript-vscode-sh-plugin--pluginProbeLocations/home/ec2-user/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/extensions/typescript-language-features--localeen--noGetErrOnBackgroundUpdate--validateDefaultNpmLocation

and

/home/ec2-user/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/node/home/ec2-user/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/extensions/node_modules/typescript/lib/typingsInstaller.js--globalTypingsCacheLocation/home/ec2-user/.cache/typescript/3.9--enableTelemetry--typesMapLocation/home/ec2-user/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/extensions/node_modules/typescript/lib/typesMap.json--validateDefaultNpmLocation

These plugins are doing Typescript things. I'm working in JS, and would be fine with not having TS LSP enabled features.

In general, it would be great if vscode-server could cap the CPU usage of extension processes, such as putting them in a cgroup with cpu.weight/cpu.max.

jaredp avatar Jul 05 '20 21:07 jaredp

/cc @mjbvz in case the tsserver has a way of limiting CPU usage.

Marking as feature request for the cgroup suggestion.

chrmarti avatar Jul 07 '20 12:07 chrmarti

This extension caused a server crash this morning by utilizing 193% of the ec2 CPU, so this seems to still be an issue FYI

mitchhankins01 avatar Nov 04 '20 19:11 mitchhankins01

This is also an issue for me, and this post solved/explained it: https://medium.com/good-robot/use-visual-studio-code-remote-ssh-sftp-without-crashing-your-server-a1dc2ef0936d

However, disabling the extension disables it globally. I'd love to 1) have this not happen at all and/or 2) be able to disable the extension only for Remote SSH usage.

EvilJordan avatar Dec 03 '20 00:12 EvilJordan

In my opinion this should be a bug. intelisense in VS Code remote is ultra slow, and it's caused by this extension somehow missbehaving. The moment I type something, I get CPU usage over 100 on the tsserver process:

/home/namir/.vscode-server/bin/f80445acd5a3dadef24aa209168452a3d97cc326/node --max-old-space-size=3072 /home/namir/.vscode-server/bin/f80445acd5a3dadef24aa209168452a3d97cc326/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /tmp/vscode-typescript1000/096c6cf00a06191a9c6a/tscancellation-16e5cf8fc136d39a8478.tmp* --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation

I don't think this should be expected, because this renders using TS or JavaScript with nice intelisense (one of the main features of vscode) quite a pain.

It seems like, as of now, the only solution is disabling it and losing these nice features... :(

namirsab avatar Feb 22 '22 17:02 namirsab

The ssh component in VSCode cause 130% CPU load on the server what is unaccessable because of this! +1

robozb avatar Jun 12 '22 12:06 robozb

yes, this is a bug

robozb avatar Jun 12 '22 12:06 robozb

@chrmarti @bamurtaugh 2 years later this issue is still occurring. Is there anything we can do to help get this resolved?

DocterDum avatar Jul 20 '22 02:07 DocterDum

@DocterDum Which process do you see using too much CPU? Is your repository checked out on a Windows or macOS filesystem and mounted into the container? In that case: Does using F1 > Remote-Containers: Clone Repository in Container Volume... result in better performance?

chrmarti avatar Jul 20 '22 09:07 chrmarti

Hey @chrmarti,

Sorry for the delay, I had to move my workload to a different machine so I could test on this one without interruptions, and then had issues actually capturing what was using the CPU (Machine became inoperable at 100% CPU usage).

The offending process is vscode-server's Node. I am not working with a repository or containers, I'm using Remote - SSH.

psOutput.txt

DocterDum avatar Jul 28 '22 05:07 DocterDum

I'm just posting a comment here to keep this thing going. Is this being looked at? I had an issue today with a development server that kept going down because /home/user/.vscode-server/bin/[...]/node was using all the CPU. I have disabled Intelephense in my VS Code, that seems to have helped, but I want those features.

BrianPittVP avatar Sep 21 '22 16:09 BrianPittVP

i am seeing the same thing. For me, I observe that these processes not only eat CPU, but a lot of RAM, which causes my EC2 dev instance to start thrashing SWAP when it runs out of RAM...which in the end forces me to reboot the entire instance because everything becomes virtually unresponsive.

mhempel-unl avatar Sep 27 '22 21:09 mhempel-unl

https://github.com/microsoft/vscode-remote-release/issues/3319#issuecomment-1197693307 shows the html language server using a lot of CPU. Maybe this has been fixed since @aeschli?

@BrianPittVP @mhempel-unl Could you open new issues with the output from ps ax in the remote included?

chrmarti avatar Sep 28 '22 08:09 chrmarti

That's interesting. I wasn't aware of problems in the HTML language server. Do you have that reproducible? The HTML server only looks at a single HTML file (no following of references). If you find the file that triggers the load and could send me that file (or a similar one) then I can investigate.

aeschli avatar Sep 28 '22 09:09 aeschli

Same problem. My RP4 is close to a heart attack.

Edit: I just figured out that this issue only exists if I open the root directory. /home and /opt are fine (15% CPU usage vs. 99%)

Dokw0N avatar Nov 27 '22 16:11 Dokw0N

I have been experiencing the same issue in 2023 and i solved it by disabling Intelephense

mosestenai avatar Apr 12 '23 09:04 mosestenai

Same issue here and I don't ever have Intelephense.

SlimGary avatar Apr 16 '23 02:04 SlimGary

Just ran into this issue; had node at 300% cpu usage on our linux development server running intellephense and vs code server. We were having intermittent latency issues on that server for days and didn't know why. My boss is now not allowing me to use VS Code lol***

***half laughing half crying

JS-GitRepo avatar Apr 28 '23 22:04 JS-GitRepo

we are in 2023 and after 2-3 years it's not solved?! what the hell vscode guys doing?

mahdian888 avatar May 05 '23 21:05 mahdian888

The problem still present.

pistoletov1974 avatar May 09 '23 16:05 pistoletov1974

The issue is still there. It killed the dev machine this morning. The solution I use normally is to connect separately from a terminal, delete the .vscode-server folder and connect again afterwards with VSCode.

I have disabled typescript & other things suggested by the community, but doesn`t solve anything.

It seems that the "node" processes don't kill themselves after disconnecting from the server either. That's what's killing it at least for me. There are constantly 2 of them running when that happens with over 50% CPU usage each.

CreepyJoker avatar May 24 '23 08:05 CreepyJoker

If I catch it on time (before the machine entirely seizes up), I can typically run a "killall node" to get rid of all the node processes that the VSCode server spawns and recover the machine without reboot. It will make my SSH connection via VSCode disconnect and reconnect, but that's acceptable as long as I have everything saved. In rare cases, however, I am forced to restart the entire remote server (in my case via the AWS EC2 web console). My recommendation is to see if you can make the remote machine have more RAM (easy if it's a virtual instance, not so easy otherwise). This helps reduce the frequency with which this happens. From my observations, this occurs because the VSCode node processes consume all the available RAM after a while, and as a result, SWAP will be used after a certain point, which puts extreme load on the storage in your system, which is what is slowing everything down ultimately.

mhempel-unl avatar May 24 '23 11:05 mhempel-unl

I had this when I opened remote root (server froze), and it was not a Typescript problem. Unsure if it was an extension problem or not, but I had very few extensions, mostly default ones.

alexlyzhov avatar Jun 22 '23 19:06 alexlyzhov

I had same problem. It helped me: First I thought that some extension in vscode may cause this problem, and I deleted several of the which I never used. Some ssh remote connection but not main that can connect vscode by ssh to my server. It decrease my cpu usage by 25%. Second I notice that vscode always tells me about - I can't read all files on server, so I thought that vscode trying to do that on a cycle and can't stop, just trying and trying. So I did this: https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

It helped me completely.

igorkolganov avatar Aug 11 '23 03:08 igorkolganov

I have this problem as well. Seems like removing the root directory from explorer reduced the node command's CPU usage from 100% to <1%. Maybe the file scanning isn't a scalable feature?

lloydtripp avatar Oct 16 '23 21:10 lloydtripp

The issue I'm facing is CPU spike when I open the GUI for vscode-remote (no code action taken), followed by server crash.

henrymcl avatar Dec 23 '23 15:12 henrymcl

Issue still there!

rubinchyk avatar Feb 14 '24 08:02 rubinchyk

I had the same issue just today! Solution for me was to uncheck the "search:follow symlinks" in preferences > settings

Celezak avatar Feb 21 '24 09:02 Celezak