Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it normal that the Angular-CLI is much slower in wsl2 than the default powershell?

In my recent projects I was working with Angular and the Angular-CLI and I noticed that basic CLI commands like ng g c, ng serve, ng build etc. take much more time in the wsl2 terminal (using ubuntu 20.04) than on the default powershell.

Any opinions or recommendations how to solve this problem?

like image 944
Cowas Avatar asked Jul 28 '20 08:07

Cowas


1 Answers

If your project files are stored on the Windows filesystem and accessed/launched from WSL2, then yes, it's "normal" (or rather, known). The Microsoft documentation mention this behavior:

If you will be using your WSL Linux distribution to access project files on the Windows file system, [...] you will achieve faster performance across the OS files systems by using WSL 1.

I was experiencing the same slowliness with an Angular project using WSL2, and my files where on the Windows filesystem.

"Any opinions or recommendations how to solve this problem?"

  1. In my case, copying the project files from the Windows filesystem to the WSL2 filesystem (e.g. $HOME/src) fixed the performance issues. And in this configuration, WSL2 is effectively way faster than WSL1 :)

  2. If you need to keep the source in a Windows folder (perhaps due to your development team workflow), then you may want to downgrade to WSL1, assuming you don't need any of WSL2's features. Keeping both WSL1 and WSL2 sessions around can make sense for this reason. You can backup/clone your existing session (see wsl --export and wsl --import) and set the WSL version for a distro with wsl --set-version.

  3. You might also consider sharing the Windows folder and mounting it via CIFS. Reports are that this is much faster (although not as fast as ext4). See this github issue and the suggested workaround from EvilVir on July 4th.

like image 190
Tazaf Avatar answered Oct 12 '22 15:10

Tazaf