microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.63k stars 282 forks source link

High CPU usage by vscode-server/typescript #3319

Open jaredp opened 4 years ago

jaredp commented 4 years ago

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.

chrmarti commented 4 years ago

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

Marking as feature request for the cgroup suggestion.

mitchhankins01 commented 3 years ago

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

EvilJordan commented 3 years ago

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.

namirsab commented 2 years ago

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... :(

robozb commented 2 years ago

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

robozb commented 2 years ago

yes, this is a bug

DocterDum commented 2 years ago

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

chrmarti commented 2 years ago

@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?

DocterDum commented 2 years ago

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

BrianPittVP commented 2 years ago

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.

mhempel-unl commented 2 years ago

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.

chrmarti commented 2 years ago

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?

aeschli commented 2 years ago

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.

Dokw0N commented 1 year ago

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%)

mosestenai commented 1 year ago

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

SlimGary commented 1 year ago

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

JS-GitRepo commented 1 year ago

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

mahdian888 commented 1 year ago

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

pistoletov1974 commented 1 year ago

The problem still present.

CreepyJoker commented 1 year ago

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.

mhempel-unl commented 1 year ago

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.

alexlyzhov commented 1 year ago

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.

igorkolganov commented 1 year ago

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.

lloydtripp commented 11 months ago

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?

henrymcl commented 9 months ago

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

rubinchyk commented 7 months ago

Issue still there!

Celezak commented 7 months ago

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

ClemZh commented 2 months ago

Hello everyone,

I am reoppening this issue because i encountered a scimilar problem. I have 2 VM of similar configuration that i connect to using remote-ssh. I am encountering the problem on one of these machine where without doing anything at first i can see fluctuating usage of cpu where most cores are used at 20% or more (see image 1) image and most of it in yellow (monitoring done though htop). When idle on the second VM i have this: image I can then see when i try running a program that most of my cpu usage is yellow with almost nothing going to support the running program (see image 2) image How it should be (result from running on the second VM): image

Does anybody know what i can do to solve this problem ?

I have tried the solution of unchecking "search:follow symlinks" didnt work (solution of Celezak) I have tried removing root from explorer and also maxed the max_user_watched but didnt work either (solution of igorkolganov) I have tried the killall node solution but when i do this i lose the ssh connection which means i have to refresh the page and the problem still reappears (can't reconnect without refreshing) I dont have intelephense I don't think its a problem of vscode extensions as I have the same extensions on the two VMs

Then I had someone try running a program using mobaxterm and we can see the same problem so maybe the problem comes from the VM in itself. Have any tried this approach to see if the problem came from the VM and not vscode ?

Also i wanted to add that when i check iotop, the two machine are scimilar. When i run iostat -xz 1 I have more than 60% in %steal when running and 15-20% when idle The process running in both VM are the same with the one working without problem having a few more running.

If someone can point me to another issue this one does not correspond i would greatly appreciate it.