How to increase WSL/docker container performance on quite common laptop?
Asked Answered
O

2

2

I have this PC configuration, which should have quite normal performance compared to common laptops:

ASUS TUF GAMING A15  
AMD Ryzen 7 4800H  
16GB RAM on 3200 MHz  
SSD  
64b Windows 10

First, I setup WSL2 and it was rather slow and I realized that the OpenSuse over WSL was probably swapping, because the processor has a lot of cores, but the 16GB was not enough for it.
So basically I open .wslconfig and set processors=2 and swap=0, it greatly improved performance of the WSL, probably stopped swapping.

  1. Was it a good idea?

So I was using the WSL quite happily, but after some time, I needed to install VMware for testing some functionality and it worked until the first reboot of the virtual machine and after that I realized that I can't use both WSL and VMware on 1 system, because the VMware wanted me to disable some option on Windows that was needed by WSL. (I think it was something with virtualization)

But after using the VMware I used the WSL again and realized that it's way slower. I checked the changes from the git, I rebuilt everything, I reverted to versions as before, but it was still way slower than before. I needed to start using docker container at that time (because of different reason), it was running quite fast at first so I did not pay much attention. But then I realized that some operations run very slowly and I did not know, why. Then I realized it must have been that VMware, so I uninstalled it and the WSL got faster, only the WSL, but the slowness in docker container remained.

When I check a Task Manager, CPU and Disk seem totally fine and Memory seems fine as well. So I guess the docker container is probably not using all available resources? The task runs 30 minutes instead of running 10 seconds which runs on similar PC directly, without docker container, it's huge difference...

Before running task in docker container: Performance Processes

While running task in docker container: Performance enter image description here

  1. How to set VSCode to make the docker container use much more resources and run the task almost as fast as without running it in a docker container?
    I realized it's maybe related to Antimalware Service Executable process, which takes around 5% CPU when running the task and uses Microsoft Defender Antivirus Service service. Can it be the problem? If so, how to add exception for the docker container or VSCode which runs it, in the least intrusive way? Disabling Real-time protection only removed its 5% CPU usage, but did not make the container task any faster.

I called docker stats and it's really not using almost any resources at all, see: docker stats

Obla answered 3/9, 2020 at 14:13 Comment(0)
F
3
  • On a Linux file system: /home/yourdir in WSL2
  • On a Windows file system: /mnt/c/yourdir

Internally converts file formats between Windows (NTFS) and Linux (extf).

Also:

docker on wsl2 very slow

Feuilleton answered 21/9, 2020 at 17:55 Comment(0)
F
1

VSCode dev containers is supposed to make this kind of setup repeatable / shareable, but on Windows I've found the performance to be unusable which all seemed to boil down to the speed delay in wsl2 mapping files to the host.

I've settled on running VSCode and docker inside a Linux VM on Windows, and have a 96% time saving in things like running up a server and watching code for changes making this setup my preferred way now.

The standardisation of devcontainer.json and being able reliably share dev setup between developers, and even to use github codespaces if you're away from your normal dev machine make this whole setup a pleasure to use.

see https://mcmap.net/q/219762/-nestjs-cli-very-slow-in-docker-container-on-windows-with-visual-studio-code for detailed timing comparison and setup details

Fizzle answered 28/6, 2022 at 14:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.