WSL: Windows `.exe` execution is very slow when `.exe` is in WSL filesystem
Version
Microsoft Windows [Version 10.0.22621.521]
WSL Version
- WSL 2
- WSL 1
Kernel Version
5.15.57.1
Distro Version
Ubuntu 20.04
Other Software
No response
Repro Steps
# Copy a Windows executable file to WSL file system
cp /mnt/c/WINDOWS/system32/whoami.exe /tmp
# Execute copied Windows .exe from WSL's filesystem
/tmp/whoami.exe
Expected Behavior
Windows executables run quickly in WSL.
Actual Behavior
Executables from /mnt/c run quickly. Same executables copied into WSL’s Linux’s filesystem run horribly slow.
WSL hangs for a long time when starting execution of a Windows .exe file. During the hang it doesn’t respond to interrupts such as ctrl + c.
$ /mnt/c/WINDOWS/system32/whoami.exe exec time 0s
$ /tmp/whoami.exe exec time 90 s
Diagnostic Logs
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 35 (1 by maintainers)
Hi, This is happening for me regardless of which WSL kernel I am using.
It happens to me if I use the bundled WSL that comes with Windows when you turn the feature on (The wsl.exe is located in C:\Windows\System32), but also if I use the WSL that you can install from the Microsoft store (App name: “Windows Subsystem for Linux”). I tried to run both “Debian” and “Ubuntu” distributions, and it happens on both.
Also, this is happening since some time on the old WSL1, even if I did not do any WSL changes (before the exes were running fine). Then I tried to install “Windows Subsystem for Linux” from Microsoft store, install Ubuntu distribution, but the very same issue is happening.
My current WSL version:
The “bundled” wsl.exe that is in the Windows System32 folder has a
File version: 10.0.10941.2311.Interestingly, when running WSL, the “new” WSL still runs as a child process of the “bundled” WSL (but I guess that’s expected right?):
For me, it’s not only that .exes within WSL filesystem are slow, but also even exes outside WSL are slow if launched with a $PWD that is inside WSL. But if you launch them with a PWD of /mnt/c and then use some means (eg powershell’s Start-Process -WorkingDirectory) to set the correct working directory from the windows side, then it’s nice and fast.
Thanks for sharing your findings! I’ve tried to install 5.10.102.2 version following your link. Starting
wsl_update_x64.msithrows the error:Starting This update only applied to machines with the Windows Subsystem for Linux.
Updating with
wsl.exe --updatebrings kernel5.15.90.1, which is still affected by the issue:I am on Windows 10. I think I occasionally observed even just ls being super slow to list files in /mnt/c, but it’s been a while since I’ve seen that. Launching exes is consistently slow though.
It always seems to be just over 10 seconds for me which makes me wonder if there could be some kind of timeout going on.
@lucidfrontier45 Looks like you already figured this out, but (for anyone else), you can uninstall the Preview just like you do with any Store application. After uninstalling (typically no reboot required), you’ll be back to the built-in WSL release.
So, for example:
wsl --shutdownOf course, you can also do the same through the “Add or Remove Programs” settings.
I encountered the same problem. As @NotTheDr01ds said, I removed wsl preview (now the kernel version is back to
5.10.102.1-microsoft-standard-WSL2) and the problem was fixed.