I'm using Ubuntu 18.04 on WSL2 and when I run an .exe from the Windows file system, it executes normally. But when I copy the .exe to the Linux file system it is excruciatingly slow. See example below:
(18.04)geert@SEA-WIN10-02:~$ time /mnt/c/Windows/system32/whoami.exe
geert
real 0m0.071s
user 0m0.000s
sys 0m0.003s
(18.04)geert@SEA-WIN10-02:~$ cp /mnt/c/Windows/system32/whoami.exe .
(18.04)geert@SEA-WIN10-02:~$ time ./whoami.exe
geert
real 0m10.198s
user 0m0.002s
sys 0m0.000s
The same happens when I use Ubuntu 20.04 or 22.04.
It started doing this recently, after my WSL2 upgraded (beyond my control).
I'm using Linux on WSL2 to cross-compile for ARM. I'm using a Windows tool that converts the Intel Hex output to an encrypted version for the bootloader. This tool is now slowing down the build. The build used to take 4 minutes and now it takes 17. The tool hasn't changed; it's taken from version control and it hasn't changed for years.
Another side-effect is that every application becomes very slow to start after the build has completed. For instance, it takes 27s before the Task Manager window appears after clicking on it in the taskbar, same for Acrobat Reader or any other application; they all take between 10 and 30s to start. CPU usage (less than 3%) and memory usage (around 35%) are 'normal' and they don't 'spike' when starting an application.
It is not fixed by running wsl --shutdown. I have to restart my system to get applications to start up immediately again.
Version of WSL2 I'm using:
PS C:\Users\geert> (get-item C:\windows\system32\wsl.exe).VersionInfo.FileVersion
10.0.19041.2311 (WinBuild.160101.0800)
PS C:\Users\geert> wsl --version
WSL version: 1.0.3.0
Kernel version: 5.15.79.1
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.2486
PS C:\Users\geert> wsl --status
Default Distribution: Legacy
Default Version: 2
PS C:\Users\geert> wsl --update
Checking for updates.
The most recent version of Windows Subsystem for Linux is already installed.
There is a WSL bug report regarding this issue but it was caused by Windows Subsystem for Linux Preview but I'm not using that. I'm using the latest official release version of WSL2.
Anyone any idea why this is happening and how to fix it?
Update: I tested this on another system with an older version of WSL2 and here everything works fine (the build takes 3m50s). This version of WSL2 is:
PS C:\Users\geert> (get-item C:\windows\system32\wsl.exe).VersionInfo.FileVersion
10.0.19041.2311 (WinBuild.160101.0800)
PS C:\Users\geert> wsl --version
Invalid command line option: --version
Copyright (c) Microsoft Corporation. All rights reserved.
...
PS C:\Users\geert> wsl --status
Default Distribution: Ubuntu
Default Version: 2
...
Kernel version: 5.10.16
Surprisingly, the wsl.exe.VersionInfo.FileVersion for both systems is identical.
My tentative conclusion is that the WSL2 update is broken.
The 'old' version of WSL2 on my 2nd system has a 'rollback' option:
PS C:\Users\geert> wsl --version
Invalid command line option: --version
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: wsl.exe [Argument] [Options...] [CommandLine]
...
--update [Options]
If no options are specified, the WSL 2 kernel will be updated
to the latest version.
Options:
--rollback
Revert to the previous version of the WSL 2 kernel.
But the WSL2 version on the system with the issue doesn't have the 'rollback' option anymore (but does have the '--version' option).
How should I fix the issue, now I can't roll back WSL2?