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

WslLogs-2022-10-04_14-00-34.zip

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 35 (1 by maintainers)

Most upvoted comments

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.

$ time /mnt/c/WINDOWS/system32/whoami.exe
xx\yyyy

real    0m0.363s
user    0m0.002s
sys     0m0.000s

$ time /tmp/whoami.exe
xx\yyy

real    2m0.210s
user    0m0.001s
sys     0m0.000s

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:

wsl --version
WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3208

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?): image

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.msi throws the error:

Starting This update only applied to machines with the Windows Subsystem for Linux.

Updating with wsl.exe --update brings kernel 5.15.90.1, which is still affected by the issue:

$ time ./whoami.exe
xxx\yyyg

real    1m20.500s
user    0m0.004s
sys     0m0.000s

It becomes very slow whenever I try to access /mnt/c. But some computers work perfectly fine. I only see this happened to Windows 11.

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 --shutdown
  • Hit the <kbd>🪟</kbd> (Windows) key to bring up the Start menu
  • Start typing “Subsystem”
  • Right-click on the “Windows Subsystem for Linux Preview” result in the Start menu
  • Select “Uninstall”

Of 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.