Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Windows exe from WSL is slower than from native Windows #9080

Closed
1 of 2 tasks
lucidfrontier45 opened this issue Oct 28, 2022 · 10 comments
Closed
1 of 2 tasks

Comments

@lucidfrontier45
Copy link

lucidfrontier45 commented Oct 28, 2022

Version

Microsoft Windows [Version 10.0.22621.675]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.57.1

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

  1. sudo apt install mingw-w64
  2. download https://gist.github.com/lucidfrontier45/c83a58ff423f26dc0feb9ce84ea8f836#file-main2-cpp and save as main.cpp
  3. x86_64-w64-mingw32-g++ -O3 --std=c++17 --static main.cpp
  4. put compiled a.exe to /mnt/c
  5. run /mnt/c/a.exe from WSL Ubuntu terminal
  6. run C:\a.exe from Windows Powershell terminal

Expected Behavior

5 and 6 end in the same duration

Actual Behavior

6 is twice slower than 5.

Diagnostic Logs

No response

related #8943

@lucidfrontier45
Copy link
Author

This does not happen for the stock WSL (kernel 5.10.102.1)

@ghost
Copy link

ghost commented Nov 1, 2022

endl causes a flush. Meaning you have synchronous write output blocking forward progress.

I'm closing this as designed. We could bump buffer sizes, but I doubt that would do much here.

@ghost ghost closed this as completed Nov 1, 2022
@lucidfrontier45
Copy link
Author

@pmartincic

Hi. endl flush is done only once at the end, not inside the for loop. I don't understand why it cause the performance drop.

I also mentioned in the comment that this problem doesn't happen on the stock WSL (kernel 5.10.102.1). Is it really as designed ?

@ghost
Copy link

ghost commented Nov 2, 2022

Are you running a custom kernel?

@lucidfrontier45
Copy link
Author

lucidfrontier45 commented Nov 2, 2022

@pmartincic

The stock WSL (kernel 5.10.102.1) does not have this problem.
After running wsl --update in powershell, the kernel became 5.15.57.1 and this problem happened.

@ghost ghost reopened this Nov 2, 2022
@ghost
Copy link

ghost commented Nov 2, 2022

Depending on what the application does there is always going to be some hit on performance by running through wsl.

However, if you're telling me that you updated WSL, and then saw a performance decrease, with no custom kernel. Then there is probably something for us to look at.

@lucidfrontier45
Copy link
Author

However, if you're telling me that you updated WSL, and then saw a performance decrease, with no custom kernel.

Yes, that's exactly what I am saying.

@DoctorWho8
Copy link

@lucidfrontier45 what did you do to update your kernel from 5.10.102.1 to 5.15.57.1?

I've got:
PS C:\Users\hanso\OneDrive\Desktop> wsl --update
Checking for updates...
No updates are available.
Kernel version: 5.10.102.1
And that's from running things inside PowerShell both normal levels and Admin levels.

@lucidfrontier45
Copy link
Author

lucidfrontier45 commented Nov 3, 2022

@DoctorWho8 I just did wsl --update in normal level PowerShell. After it now I have WSL 0.70.4.0 with Kernel 5.15.68.1. Previously wsl --update results in WSL 0.66.2 and Kernel 5.15.57.1. Both WSL/Kernel version have the reported problem. Only the stock WSL before applying wsl --update doesn't have the problem but I don't know its exact version since wsl --version doesn't work in the stock WSL.

Below are the logs (in Japanese)

PS C:\Users\lucid> wsl --update
インストール中: Linux 用 Windows サブシステム
Linux 用 Windows サブシステム はインストールされました。 (Windows subsystem for Linux is installed)
PS C:\Users\lucid> wsl --version
WSL バージョン: 0.70.4.0 (WSL version)
カーネル バージョン: 5.15.68.1 (Kernel version)
WSLg バージョン: 1.0.45
MSRDC バージョン: 1.2.3575
Direct3D バージョン: 1.606.4
DXCore バージョン: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windowsバージョン: 10.0.22621.675

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants