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 · 322 comments
Open

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

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

Comments

@Mika56
Copy link

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

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

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

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 commented Aug 12, 2016

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

@aseering
Copy link
Contributor

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

@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 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 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 commented Oct 12, 2016

Is this issue beeing worked on?

@fpqc
Copy link

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

Any updates on this?

@fpqc
Copy link

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 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 commented Jan 24, 2017

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

@nickjj
Copy link

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

@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 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 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

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

@chx
Copy link

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

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.

@yay
Copy link

yay commented Sep 8, 2022

Basically, this isn't a simple problem

@SvenGroot I thought Microsoft is making money solving hard problems (like amazing Github Copilot stuff and natural text-to-speech). Any progress on those items after 4 years?

@GrimzEcho
Copy link

GrimzEcho commented Oct 11, 2023

Just changing to a moderately large project directory (~20,000 files) on /mnt via cd takes almost 5 minutes to complete. This happens for each new terminal that accesses the folder.

It's disappointing that this is still a big issue 7 years after the ticket was opened.

@ylluminate
Copy link

@BrianHVB curious, while I don't use Windows anymore for development (macOS), does this happen with WSL2?

@GrimzEcho
Copy link

@ylluminate Yes - it is specific to WSL 2. I haven't used WSL 1 in almost two years, but I never encountered the same performance issues (on the same 20,000 file repo).

Putting the repo under WSL-Linux's virtual disk (e.g. in the /home) folder eliminates the issue, but then the only way you can access the files from the container is over a network share, and that causes problems for JetBrains IDEs and other tools. It also means having to maintain two separate repositories if you need to work on the project from both Windows and Linux contexts.

@EmpiricEmpire
Copy link

Putting the repo under WSL-Linux's virtual disk (e.g. in the /home) folder eliminates the issue, but then the only way you can access the files from the container is over a network share, and that causes problems for JetBrains IDEs and other tools. It also means having to maintain two separate repositories if you need to work on the project from both Windows and Linux contexts.

Well, if you're onto workarounds, why don't you just install a Linux distro?

@GrimzEcho
Copy link

GrimzEcho commented Oct 11, 2023

@EmpiricEmpire Do you mean installing a Linux distribution under WSL 2? I have several, that is where this problem is originating. I want to operate on the project's source code using Windows-based GUI tools such as my JetBrain's IDEs, while compiling and running the project in Linux via WSL 2.

@EmpiricEmpire
Copy link

@EmpiricEmpire Do you mean installing a Linux distribution under WSL 2? I have several, that is where this problem is originating. I want to operate on the project's source code using Windows-based GUI tools such as my JetBrain's IDEs, while compiling and running the project in Linux via WSL 2.

Well, clearly you have a distro under a WSL 😄 I just googled and JetBrain produces Linux binaries of their IDE. But even if it wouldn't you could run it under WINE just fine performance-wise, so… 🤷

@EmpiricEmpire
Copy link

@BrianHVB sorry, don't get me wrong, I get you used to Windows and why would you switch, etc… Which is exactly why my first message started with "if you're onto workarounds". It's just that having a single repo might be easier, that's all 🤷 Not insisting tho, do whatever you like.

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