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:
- I am running ubuntu 20.04
- There is a bug in WSL1 which breaks sleep in glibc.
- The fix is to use ubuntu 18.04
- 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.