WSL: WSL2 FS access to Windows on W11 is much slower than on Win10
Version
Microsoft Windows [Version 10.0.22000.1335]
WSL Version
- 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® Core™ 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
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 31
- Comments: 20
Come on, Microsoft!
Yes, since upgrading to win 11 I noticed that even typing is sometimes slow and laggy in my IntelliJ IDE when projects are open in WSL2,
Hi! Are there any updates on this task? This issue causes a lot of problems for those who work directly with WSL filesystem…
Anything related to WSL2 on IDEA / PyCharm is painfully slow to the levet that tool is not usable. It can’t read Python source / installed libraries and even having WSL mentioned somewhere in config file is making IDE slow (IDEA was refreshing it and and tool was hanging).
Knowing it, I wouldn’t upgrade to Windows 11. Please fix it.
wow, even on Win10, using the mounted /c, access is a hundred times as slow (100x) for me! (For you it was only 30x as slow.) I have an M2 device (3000MB/s), so my numbers looked like this for Win10 (I don’t have Win11).
But it seems openat takes the same share of the time on Win10. All of it just takes longer for you on Win11.
Maybe you can do an strace for your Win10 too, to also have those numbers.
For me on Windows 11 file access gets slower and slower until it completely hangs…
https://github.com/microsoft/WSL/issues/9654
I have this issue on windows 10
Hi there! I have Win11 and i just installed WSL 2
When the Ubuntu is running, my explorer and other programs get super slow (Animation , opening files || apps …) not only in the Linux Directory but also in other Drivers! Windows is on samsung SSD 2TB Ubuntu is located on another SSD M.2 2TB I had the Task Manager running to see if it is a Hardwere thing, and it isn’t. (2% used)
https://youtrack.jetbrains.com/issue/IDEA-293604/IntelliJ-is-slow-hanging-when-working-with-WSL-filesystem The discussion on JetBrains issues tracker. There are conversations about adding exclusions to Windows Defender helps.
I don’t think this is recommended.
Here is Win10.
Everything is good on Linux. Win has ~ 1 second, which is much slower, but not a big issue. The heaviest call is
openat(2)againI can live with Win10 performance, but not with Win11