WSL2 FS access to Windows on W11 is much slower than on Win10
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Version
Microsoft Windows [Version 10.0.22000.1335]
### WSL Version
- [X] WSL 2
- [ ] WSL 1
### Kernel Version
Linux version 5.15.79.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Wed Nov 23 01:01:46 UTC 2022
### Distro Version
Ubuntu 20.04
### Other Software
python
### Repro Steps
Ensure defender is disabled
```
PS C:\> Set-MpPreference -DisableRealtimeMonitoring $true
PS C:\> Get-MpPreference | select DisableRealtimeMonitoring
DisableRealtimeMonitoring
-------------------------
True
```
On ubuntu WSL measure performance with oneliner that writes one byte to a file, reads it back and obtains file info (stat). It does so 1000 times.
First, measure it on Windows 10 (``[Version 10.0.19045.2364]``)
Win10
```
link@UNIT:~$ time python3 -c "for _ in range(1000): import os; f = open('./1.dat', 'w'); f.write('1'); f.close(); f = open('./1.dat', 'r'); f.read(); os.stat('./1.dat')"
real 0m0.053s
user 0m0.023s
sys 0m0.008s
link@UNIT:~$ cd /mnt/c/temp
link@UNIT:/mnt/c/temp$ time python3 -c "for _ in range(1000): import os; f = open('./1.dat', 'w'); f.write('1'); f.close(); f = open('./1.dat', 'r'); f.read(); os.stat('./1.dat')"
real 0m1.498s
user 0m0.115s
sys 0m0.115s
```
As you could see, everything is much slower on win FS, but still usable.
Now, lets go to Win11 (``[Version 10.0.22000.1335]``)
```
link@WinDev2211Eval:~$ time python3 -c "for _ in range(1000): import os; f = open('./1.dat', 'w'); f.write('1'); f.close(); f = open('./1.dat', 'r'); f.read(); os.stat('./1.dat')"
real 0m0.054s
user 0m0.032s
sys 0m0.021s
link@WinDev2211Eval:~$ cd /mnt/c/temp
link@WinDev2211Eval:/mnt/c/temp$ time python3 -c "for _ in range(1000): import os; f = open('./1.dat', 'w'); f.write('1'); f.close(); f = open('./1.dat', 'r'); f.read(); os.stat('./1.dat')"
real 0m13.515s
user 0m0.172s
sys 0m0.895s
```
Here are 13 seconds. But user/sys time is low. On ``vmstat(8)`` output I see insanely high number of interrupts and context switches. So I assume each FS access leads to many interrupts processed on kernel thread, not accounted as process time because of that.
Lets now see syscall wallclock time:
```
link@WinDev2211Eval:/mnt/c/temp$ strace -c -w python3 -c "for _ in range(1000): import os; f = open('./1.dat', 'w'); f.write('1'); f.close(); f = open('./1.dat', 'r'); f.read(); os.stat('./1.dat')"
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
33.53 6.106872 2973 2054 2 openat
15.76 2.870026 1384 2073 read
15.20 2.767644 896 3087 fstat
14.32 2.608359 1269 2055 close
6.14 1.117568 1117 1000 write
5.16 0.938890 821 1143 26 stat
4.85 0.882534 218 4038 4032 ioctl
4.83 0.879587 216 4065 3 lseek
# ... whatever
------ ----------- ----------- --------- --------- ----------------
100.00 18.212611 19728 4066 total
```
6 seconds for 2000 ``openat(2)`` syscalls on "11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz" (one year old CPU) a little but too much, especially when it was not so slow on W10
### Expected Behavior
I expect to have 1 second for this oneliner on W11 as I had on W10
### Actual Behavior
13 seconds for the same script on W11 what took 1 second on W10
### Diagnostic Logs
_No response_
Contributor guide
Research direction
Start by reproducing the Python benchmark from the issue on WSL2 under Windows 11, comparing the Linux filesystem with /mnt/c and checking the reported strace and vmstat behavior. Use the Win10 and Win11 timings as the baseline; done means identifying and correcting the regression so the same workload approaches the expected performance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100