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

High CPU usage in Remote Desktop process with WSL2 + Ubuntu

Open ACERposS opened this issue 3 months ago • 6 comments

  • VSCode Version: 1.87.2
  • Local OS Version: Windows 10 Enterprise 22H2
  • Remote OS Version: Ubuntu 22.04.4
  • Remote Extension/Connection Type: WSL (VSCode extension v0.86.0)

I am getting high CPU usage and an unresponsive 'explorer' sidebar in VSCode in a project with somewhat deeply nested directories (React, not Java ;). The 'loading' animation at the top of the sidebar frequently displays, and some files & directories fail to open at all.

Possibly relevant detail: my workstation is managed by a domain administrator and has Windows Defender Smartscreen enabled and locked.

At the times in which the explorer hangs (mostly when renaming, copying or creating files through the explorer) I also see high CPU usage for the Remote Desktop process on my machine but no significant activity from any Nodejs process within WSL:

image

ACERposS avatar Mar 19 '24 23:03 ACERposS

Likly not an issue in the explorer, but that's where I would start to profile.

The deep tree can cause a lot of file change events. Try excluding some files with the files.exclude and watcher.exclude setting. E.g. for JavaScipt we exclude the node_modules folder

aeschli avatar Mar 20 '24 08:03 aeschli

Yeah, I don't think it's anything within VSCode itself since I don't see high CPU usage in any node processes within WSL.

I can also confirm it's not related to open file handles (I have had this before but solved it). What I have is on the order of hundreds, not tens-of-thousands:

$ lsof | awk '{ print $1 " " $2; }' | sort -rn | uniq -c | sort -rn | head -15

    552 node 837555
    468 node 837278
    462 node 837212
    238 node 837599
    210 node 837234
    210 node 837225
     72 snapd 680670
     53 systemd 391
     24 python3.1 327

The first of these processes watching 552 files appears to be the extension host process, which is what I'd expect with a project running TypeScript intellisense & ESLint:

$HOME/.vscode-server/bin/863d2581ecda6849923a2118d93a088b0745d9d6/node --dns-result-order=ipv4first $HOME/.vscode-server/bin/863d2581ecda6849923a2118d93a088b0745d9d6/out/bootstrap-fork --type=extensionHost --transformURIs --useHostProxy=true

ACERposS avatar Mar 20 '24 22:03 ACERposS

Some additional information on this: I routinely receive this popup upon opening any WSL-connected application for the first time after a reboot. It must be dismissed 11 times to silence the warning.

Screenshot 2024-03-22 143801

I have found on some occasions when my machine was essentially unresponsive that this popup was a symptom. I have seen it silently open in the background hundreds of times (perhaps once for each watched file handle?). There appears to be some correlation between the number of popups and the severity of the filesystem performance impact.

ACERposS avatar Mar 25 '24 23:03 ACERposS

How is Remote Desktop involved here? What I understood: You use Remove Desktop to connect to a Windows Machine that has WSL installed. On that Windows machine you run VS Code (under Window) with the WSL extension to work in WSL.

aeschli avatar Mar 26 '24 08:03 aeschli

No. I don't (consciously) use Remote Desktop at all. It seems as though its process interferes with a default WSL2 configuration somehow.

All the processes in question are those I'm observing on my own local machine.

ACERposS avatar Mar 26 '24 22:03 ACERposS

Sorry to chime in here. I have a very similar issue on my machine. I have Docker configured to use WSL. A while after starting docker the "Remote Desktop" starts and consumes ~10% cpu. When I terminate the "Remote Desktop" in the task manager, it starts up again. Only when I shutdown wsl (and thereby kill Docker) I can then terminate "Remote Desktop" and it doesn't start again.

Sometimes I have several instances of Remote Desktop running. Although I think this is related to me using remote connections in VS Code. I think the same happens when I use dev containers. In these two cases it somehow makes sense that the "Remote Desktop" process shows up. But for Docker + WSL alone, I find it weird.

stefanbischof avatar May 03 '24 07:05 stefanbischof