dracoblue.net

VSCode 100% CPU Usage with WSL1

When I am using windows for development reasons in combination with wsl it is usually pretty good experience. As long as you don't try to mount a windows directory into the linux subsystem, but use the storage directly there - it's nice!

The official vscode extension for wsl usually integrates nicely with visual code.

But today I experienced a very bad performance of vscode and the windows system. A short htop / taskmanager call showed: All CPUs have been in use for 100%. The process eating all resource was called: .vscode-server.

As I could not figure what the resource was doing, I did a last try by using strace on the process:

clock gettime(CLOCK MONOTONIC COARSE, (tv_sec=1105, tv_nsec=65821900})
clock gettime(CLOCK MONOTONIC, {tv sec=1105, tv_ nsec=66700700})
epoll wait( 14, Il. 1024, 4997)
clock gettime(CLOCK MONOTONIC COARSE, (tv_sec=1110, tv_nsec=66638900})
clock_gettime(CLOCK_MONOTONIC, {tv_ sec=1110, tv nsec=67747600})
clock gettime(CLOCK MONOTONIC COARSE, {tv sec=1110, tv_nsec=68671200})
clock gettime(CLOCK MONOTONIC COARSE, {tv sec=1110, tv_nsec=69583200})
clock_gettime(CLOCK_MONOTONIC_COARSE, {tv sec=1116, tv_nsec=70493200})

After a lot of research in the internet I finally found the root cause of this:

  1. I am running ubuntu 20.04
  2. There is a bug in WSL1 which breaks sleep in glibc.
  3. The fix is to use ubuntu 18.04
  4. Or upgrade to wsl2

As I wanted to get it working in wsl1 (the host did not have virtualization enabled), I tried the ubuntu 18.04 approach.

It worked like this:

c:\ wsl --set-default-version 1
c:\ wsl --install -d ubuntu-18.04
c:\ wsl -s ubuntu-18.04

When I connected with vscode to this wsl distribution - the CPU usage was back to normal again.

In nodejs, vscode, windows, wsl by
@ 22 Feb 2023, Comments at Reddit & Hackernews

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About