git status slow on DrvFS
I don't believe this is specific to git, but it exposes the problem nicely.
To do this test, I cloned Mono to /mnt/c/mono
When running time git status on WLS:
real 0m14.276s
user 0m0.375s
sys 0m36.656s
However, if I run the same command on Git Bash for windows, it runs significantly faster:
real 0m0.790s
user 0m0.015s
sys 0m0.031s
This problem is not related to the /mnt folder, as I get similar runtimes in ~/. I don't have an antivirus or firewall running (including Windows Defender).
I've also run bonnie++ to test my HD speed:
Version 1.97 ------Sequential Output------ --Sequential Input- --Random-
Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
TEST 8G 127291 58 85793 57 225356 63 446.2 455
Latency 147ms 155ms 42017us 876ms
1.97,1.97,TEST,1,1472070956,8G,,,,127291,58,85793,57,,,225356,63,446.2,455,,,,,,,,,,,,,,,,,,,147ms,155ms,,42017us,876ms,,,,,,
I believe the problem lies with random seeks per second. I've run the same command on a different linux box with an SSD (my personal machine has an SSD as well), and I'm getting about 10 times less random seeks (but equivalent of everything else). I've confirmed this theory by running dd on both Git Bash and WLS, and I get roughly equivalent numbers there as well.
I'm running on Windows Version 1607 Build 14393.82
Thanks for the feedback!
There are some known issues with file system performance. We go into a little detail on our implementation on our Blog and that should shed a bit of additional light on the situation. Also, there are some discussions on filesystem performance (my favorites are #873 and the Phoronix article from a while back).
This is not an easy problem, but it is something we are working diligently to improve. Unfortunately I can't give an ETA, but we do have some things in the pipe which will have some impact.
I did see #873 as well, but my issue is different, as it occurs anywhere in the filesystem, not just under /mnt. I'd also like to note that I've talked with other people using WSL, and they aren't experiencing nearly the same amount of slowness I've gotten. I'm unsure exactly why machine is different, but there's definitely something there.
It appears to be a problem with VolFs (/home/me/chromium/src) not captured by the Phoronix tests. If you checkout say the chromium tree with all branches and do a git status you're pretty much hooped. It takes about a minute give or take on Linux/Ext4 or Windows/NTFS with my spinning disk. On WSL/VolFs I've never been patient enough to see it return.
Updated the title because the original made cause assumptions, and many other issues have been duped into this one.
While my title may have been inaccurate, I don't think that "git status is slow" accurately describes the problem either, as it is just a symptom of the problem
Indeed. The new title merely follows the guidelines of CONTRIBUTING.md (example given: "traceroute not working"). It summarises the nature of the repro given in the OP, and is actionable. Presumably this issue# would be closed when the performance of git status on DrvFS adequately matches that of git status on say Cygwin or ntfs-3g on Linux (for some arbitrary value of adequate).
Has there been any recent progress on this? I'm experiencing crippling performance (> 30s) when running git status under WSL, which should normally take < 1s in my repo.
Just to provide a temporary solution:
#!/bin/bash
# WSL 'git' wrapper, save as /usr/local/bin/git and chmod a+x
if [ "${PWD:0:5}" = "/mnt/" ]; then
/mnt/c/Program\ Files/Git/bin/git.exe "$@"
else
/usr/bin/git "$@"
fi
Result:

@piksel You're the best! How did I not think of this before.
@jakeg - We are constantly looking at ways to improve disk perf and are making regular investment in that space. If there is anything significant to report, we will. For best updates, you can monitor the WSL release notes here. We understand the ask here. Please bear with us here as this is a major undertaking.
Here is an alternative script to @piksel just in case someone is using symlink directories like me.
#!/bin/bash
# WSL 'git' wrapper, save as /usr/local/bin/git and chmod a+x
REALPATH=`readlink -f ${PWD}`
if [ "${REALPATH:0:5}" == "/mnt/" ]; then
git.exe "$@"
else
/usr/bin/git "$@"
fi
The bash script wrapper is good, it's fast. The one thing I'm now missing is console colors, is there a fix for that?
@er1c This is not related to WSL per se, so kind of off topic, but you can force git to use colors with either --color=always or -c color.ui=always (depending on what command your issuing) i.e:
git log --graph --color=always
You can run the following commands to get colors working, depending on what you want to colorize.
log: git config color.log always
status: git config color.status always
diff: git config color.diff always
I am running the windows version of git with coloring and love the speed up.
@IkeTheDestroyer thanks!
I had to add a set HOME=%USERPROFILE% to the "Environment" tab in ConEmu to get around a bad windows-working directory, but adding --global to each of your commands works perfectly for me - and across all of my projects
While the hack to use git.exe instead of /usr/bin/git does work for most applications, it is not an acceptable solution as it requires duplicating the configuration and does not allow me to use my configured editor.
Can someone comment if the performance stays the same with the Spring Creators update?
Has anyone tried https://blog.github.com/2018-04-05-git-217-released/#speeding-up-status-with-watchman?
There's another problem: the first time that git-status is run on WSL after running it on Git For Windows shell it is painfully slow, much slower than consecutive runs.
strace indicates that on this first time, Git will see every file in the repository as untracked and stat, open and read them (but in the end nothing will be reported as changed). Next runs will be faster and this process will only happen again if you run git-status on Git For Windows' shell.
The index file is also changed between those cross-layer operations, so maybe the index is being messed up somehow (or there could be an option in Git to avoid this).
I couldn't investigate any further, but maybe that can help somehow.
(PS: I have core.filemode set to false and core.autocrlf set to true)
Is there an update ? Git seems like a pretty pivitol use case for WSL. Currrently, git is pretty much unusable on a windows filesystem.
gets worse when you using a prompt that updates based on your git status