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

Major performance (I/O?) issue in /mnt/* and in ~ (home) #873

Open
Mika56 opened this issue Aug 11, 2016 · 314 comments
Open

Major performance (I/O?) issue in /mnt/* and in ~ (home) #873

Mika56 opened this issue Aug 11, 2016 · 314 comments
Assignees

Comments

@Mika56
Copy link

@Mika56 Mika56 commented Aug 11, 2016

A brief description

As a Symfony developer, it's always been hard to get a stable/fast development environment. My current setup is a Ubuntu running under VirtualBox (using vagrant). While page generation is fast, my IDE accesses my PHP files through SMB, which is really (sometimes horribly) slow.
I'm now trying to use WSL to improve all of this. However, I'm having a major performance issue when using /mnt/* folders.
If I set up a Symfony project under /mnt/c, it is really slow. If I set it up under /home/mikael, it is very fast.

Expected results

Drives mounted under /mnt should be as fast a any other folder.

Actual results

With a new Symfony 3.1.3 project, under /home/mikael takes between 100ms and 130ms to generate the home page.
The same project under /mnt/c/ takes between 1200ms and 1500ms.

Your Windows build number

10.0.14393.51

Steps / commands required to reproduce the error

# Install PHP5
$ sudo apt-get install -y php5 php5-json

# Download Symfony installer
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony

# Download Symfony
cd
symfony new symfony_test

# Start Symfony
cd symfony_test
php bin/console server:run

Open your browser and go to http://127.0.0.1:8000/.
Once the page is loaded, refresh it (on first request, Symfony had to generate its cache).
Generation time is displayed on the bottom left
Image

You can then do the same under /mnt/c/

cd /mnt/c/
symfony new symfony_test
cd symfony_test
php bin/console server:run

Additional information

I've added my dev folders as excluded folders in Windows Defender, as well as %LOCALAPPDATA%\lxss.
I've tried having my project in ~ and pointing my IDE to %LOCALAPPDATA%\lxss\home\mikael\ but as I've later read, there is no supported way of editing WSL files.
WSL is installed in its default location under C (no strange junction or symlink), which is a healthy SSD.
My computer is attached to a domain, if this might have any influence.

@Mika56 Mika56 changed the title Major performance (I/O?) issue Major performance (I/O?) issue in /mnt/* Aug 11, 2016
@fcicq
Copy link

@fcicq fcicq commented Aug 12, 2016

with the current design of DrvFs, I guess this problem is hard to resolve. I recommend you to run a ssh server inside WSL and do the edit via ssh to bypass some other issues.

from https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/
"DrvFs also disables directory entry caching to ensure it always presents the correct, up-to-date information even if a Windows process has modified the contents of a directory."

@fpqc
Copy link

@fpqc fpqc commented Aug 12, 2016

Also @Mika56 the devs have said they are working on improving performance by redesigning parts of how file I/O works. That's probably why they haven't documented exactly how it works yet, since it is very much in flux at the moment.

@ajaykagrawal
Copy link

@ajaykagrawal ajaykagrawal commented Aug 12, 2016

there is no supported way of editing WSL files

I wonder how difficult it would be for popular IDE and text editors to become WSL aware and preserve the attribute of WSL files (the security model may have some inconsistencies but I might be ok with it)

@fpqc
Copy link

@fpqc fpqc commented Aug 12, 2016

@ajaykagrawal Some text-editors have an ability to save in-place rather than overwrite. I heard someone say that they enabled that setting in one or another text editor and it worked.

@ajaykagrawal
Copy link

@ajaykagrawal ajaykagrawal commented Aug 12, 2016

Thanks @fpqc. I don't quite know what save in-place means but I hope more editors are updated to have this ability

@Mika56
Copy link
Author

@Mika56 Mika56 commented Aug 12, 2016

@fcicq I'm using an IDE for a reason :) I need my IDE, and mounting a folder through SSH, FTP, SMB or whatever would be no improvement on my current environment

@fpqc
Copy link

@fpqc fpqc commented Aug 12, 2016

@ajaykagrawal Basically instead of writing a new file and saving over it, the text editor has a delta and applies it to the file, at least that's my guess.

@aseering
Copy link
Contributor

@aseering aseering commented Aug 12, 2016

In the old days, whenever you hit "save", text editors saved into your existing file. This was simple and efficient, but if your editor crashes or was killed mid-save, or if you run out of disk space, or if anything eelse weird happens, you might end up with a corrupt garbled mess that's half the old file and half the new file. Or it might just be completely empty / wipe out all of your data entirely, if your app implemented "save" with an initial truncate, which is easy to do by default on Linux at least.

These days, text editors almost always "save" by creating a temporary file in the same directory, writing the entire new file contents to the temporary file, and then moving the temporary file on top of the old file, overwriting the old file in the process. "Move" within a directory is guaranteed in most cases to be strictly atomic -- even if your computer loses power mid-Move, you'll always be left with either the new file or the old file; not a corrupted intermediate.

Clever, right? Saves lots of "I lost my data!" headaches. Thing is, if an application creates an arbitrary new file, there's no way for the OS to know that it's supposed to have the same magic permissions as some other existing file. That's what's breaking WSL.

Some editors let you go back to the old-style behavior. Has more risk, but avoids issues in some situations.

@fpqc
Copy link

@fpqc fpqc commented Aug 12, 2016

@aseering it looks like Windows move preserves those attribs, or at least robocopy does?

@aseering
Copy link
Contributor

@aseering aseering commented Aug 12, 2016

Read more carefully: It does an excellent job of preserving the attributes of the wrong file :-)

[EDIT] I can't speak for robocopy, just regular move, but what you want in this scenario is the opposite of what you want in most scenarios.

@fpqc
Copy link

@fpqc fpqc commented Aug 13, 2016

@aseering yep I am aware. I just thought that Windows commandline tools preserve even hidden ntfs attributes (moving is different from editing a file, since the atomic operation is done at the filesystem level, I think) like robocopy does.

@aseering
Copy link
Contributor

@aseering aseering commented Aug 13, 2016

@fpqc -- ah, I see what you're getting at. Yeah, applications can copy extended attributes, if they're programmed to do so correctly.

@Adraesh
Copy link

@Adraesh Adraesh commented Aug 16, 2016

Exactly the same "issue" detailed above, as I am as well a Symfony dev.

My SF projects are all located into /mnt/d/.... my apache2 server (running on ubuntu bash) root folder is linked using a symlink and the perfs are aweful ...

This also lead to some issue with Symfony cache system btw.

@baroso
Copy link

@baroso baroso commented Sep 7, 2016

I've not noticed any performance issues with my IDE IntelliJ/PHPStorm, but the execution of PHP/Symfony code (running LAMP/Symfony with SuluCMS installed) ist between 4-10 times slower (total execution time) than on a normal Ubuntu system ...

WSL 14915
image
second run
image

Ubuntu 14.04
image
second run
image

Why is it so slow?
Are there any workarounds, maybe moving the vendors folder of Symfony?

If you can fix this issue, it will be the best environment for developing true DOT.NET and true PHP on Windows!!!
Thanks, keep up the great work!!!

@baroso
Copy link

@baroso baroso commented Oct 12, 2016

Is this issue beeing worked on?

@fpqc
Copy link

@fpqc fpqc commented Oct 12, 2016

@baroso Yep. It's one of their top priorities after getting all the web-programming stuff working.

@nickjj
Copy link

@nickjj nickjj commented Nov 19, 2016

@fpqc Is there another issue to watch to see progress?

Slow mount performance is the only thing holding me back from upgrading to Windows 10 and using WSL.

@fpqc
Copy link

@fpqc fpqc commented Nov 19, 2016

@nickjj All I know is that the devs have said that it is a top priority, but they haven't released details on how they are going to pull it off. It did sound like they have an idea of how to do it though.

@pachkovsky
Copy link

@pachkovsky pachkovsky commented Jan 24, 2017

Any updates on this?

@fpqc
Copy link

@fpqc fpqc commented Jan 24, 2017

nope. Mum's the word on this'n. Major performance improvements I think are targeted for RS3 not RS2.

@nickjj
Copy link

@nickjj nickjj commented Jan 24, 2017

What does RS3 mean in the grand scheme of things? Will it still make it into the next official big update?

@fpqc
Copy link

@fpqc fpqc commented Jan 24, 2017

RS3 insiders builds will be rolling out probably in May. Release in December?

@nickjj
Copy link

@nickjj nickjj commented Jan 24, 2017

Thanks. Guess I'll come back next year. Hopefully things are ironed out.

Using the insider's build is out of the question for me due to the severe breach of privacy that it entails.

@bitcrazed
Copy link
Contributor

@bitcrazed bitcrazed commented Feb 13, 2017

@ajaykagrawal As a general rule of thumb, whenever the question "I wonder how difficult it would be" is asked, assume that the answer is "very, very difficult", and/or "takes an enormous amount of time with no guarantee of success" ;)

In this case, imagine trying to get the owner of every application that opens and saves text files to modify their apps to support a different way of opening the files without read locks, and writing changes to those files without destroying extended properties managed by an external process.

If the underlying issue was simple to solve, we'd likely have already solved it. However, yes, we are very aware of the issues and we do aim to work on improving Windows <--> Linux filesystem interop in the future.

@aseering
Copy link
Contributor

@aseering aseering commented Feb 26, 2017

I realize this is a hard problem, but, just reporting that I'm still (build 15042) finding DrvFs to be much slower than Linux for my common use cases, to a degree that impacts my productivity somewhat.

A good specific representative-example workload that I would like to see optimized is the Boost build process:

http://www.boost.org/doc/libs/1_61_0/more/getting_started/unix-variants.html#easy-build-and-install

The build steps should be heavily CPU-bound in the compiler; that's fine. But I would love to see the final ./b2 install command run faster. In my experience, it's many times slower on Windows than on Linux.

Note that Boost's build system is cross-platform. And the final install command is just as slow under regular Windows :-) It would be wonderful if the Windows version got faster too.

@fpqc
Copy link

@fpqc fpqc commented Feb 26, 2017

@aseering fwiw, the major performance improvements were not planned for RS2. Even 2 months ago the devs were saying it was planned for RS3.

@aseering
Copy link
Contributor

@aseering aseering commented Feb 26, 2017

@fpqc -- yep, I'm just keeping the ticket alive :-)

@rbtcollins
Copy link

@rbtcollins rbtcollins commented May 26, 2019

@mscraigloewen I think I've gotten pretty close to (at least one) of the major performance issues vis-a-vis 'IO performance' for WSL - I'm sure there's a lot of detail thats not visible from the outside, but the serialisation I've identified is almost certainly affecting quite a lot of different workloads; I presume its contained to a single process - if it crosses processes then even more... rust-lang/rustup#1866 (comment) - I'd be delighted to supply more information or help your team see what I'm seeing if that will help.

Edit - this is almost certainly what was pointed out back #873 (comment)

@EmpiricEmpire
Copy link

@EmpiricEmpire EmpiricEmpire commented Jun 14, 2019

So, initial benchmarks of WSL1 vs WSL2 have been released https://www.phoronix.com/scan.php?page=article&item=windows-10-wsl2 Turns out, although WSL2 improved on IO performance, but it regressed CPU one. *claps*

@MikeGitb
Copy link

@MikeGitb MikeGitb commented Jun 15, 2019

I'll reserve judgement until comparisons with regular BMI solutions are out, but it is a bit disappointing.

I also hope there will be benchmarks for file- accesses through 9P. If that performs noticeable worse than wsl1 access to /mnt/c/... I'm not sure I'll have a lot of use for it - but that's just due to my particular work flow.

@Coder-256
Copy link

@Coder-256 Coder-256 commented Jun 16, 2019

Benchmarks aside, I've found that the IO improvements are great. npm install now works where previously it would give a "permission denied" error (I needed to use npm in Windows). Plus apt upgrade is MUCH faster during the unpacking stage. Overall I've noticed it's much faster and responsive (I guess the IO improvements outweigh the CPU overhead). Full disclosure, I haven't tested inter-OS IO. Also it looks like you can downgrade easily if you want to.

If you want to try upgrading to WSL 2, a word of advice: disable real-time protection on Windows Defender or your antivirus while upgrading, it goes much faster.

@Gabrielcarvfer
Copy link

@Gabrielcarvfer Gabrielcarvfer commented Oct 30, 2019

Kind of weird, but I've noticed that WSLv2 can be much slower (>1000x) than WSLv1 while working with CMake on (/mnt/*). Strace -c results

@slikts
Copy link

@slikts slikts commented Oct 30, 2019

WSL 2 is supposed to be faster only if you use the Linux filesystem.

@chx
Copy link

@chx chx commented Oct 30, 2019

How's I/O performance when reached over \\WSL$ ? I run phpstorm in Windows and LAMP stack in WSL1, currently the files on /mnt/c with known performance issues, I was looking forward to WSL2 but if the shared performance is still bad then :(

@Gabrielcarvfer
Copy link

@Gabrielcarvfer Gabrielcarvfer commented Oct 30, 2019

@chx I'm not running a generic benchmark, so I would recommend you to run the tests with your application.

@slikts Doesn't seem to be the case with /home/*/. It is ~3x faster than WSLv2 /mnt, but still >10x slower than WSLv1 (I reran with WSLv1. I've forgotten to remove the cache before running...). Strace -c results

@chx
Copy link

@chx chx commented Oct 30, 2019

frustrating you know very well people on ordinary channels can't use WSL2 and rely on people who got on the faster tracks to give them some info

@MichaelJCole
Copy link

@MichaelJCole MichaelJCole commented Nov 10, 2020

I wish this problem was as easy as saying "NTFS is slow" or "DrvFs is slow".

@SvenGroot, thanks for your post and explanation. I left Windows for Linux around NT and now I'm back.

You mentioned a workaround to move files off C: to D: so as to skip some of the filters causing slow downs.

I symlink from C: into Ubuntu's root so I can use graphical editors without having to go full XWindows.

$ ls
lrwxrwxrwx  1 michael michael       23 Nov  5 12:01 'Unreal Projects' -> '/mnt/c/Unreal Projects/'
lrwxrwxrwx  1 michael michael       23 Nov  5 14:11  webproject -> /mnt/c/webproject

Given what is (and 2 years of experience), are there any other workarounds?

@DemiMarie
Copy link

@DemiMarie DemiMarie commented Nov 10, 2020

One idea I just had for WSL to have its own metadata cache, and to add a filter driver that invalidates the cache when necessary.

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

No branches or pull requests