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

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 30
  • Comments: 49 (8 by maintainers)

Most upvoted comments

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

@er1c I’ve found the lack of paging on git log to be a problem also.

Forgive my lack of “bash-fu” but I came up with this as an interim hack:

#!/bin/bash                                                             
# WSL 'git' wrapper, save as /usr/local/bin/git and chmod a+x           
                                                                        
REALPATH=`readlink -f ${PWD}`                                           
ARG1=$1                                                                 
                                                                        
if [  "${REALPATH:0:5}" == "/mnt/" ]; then                              
  if [ $ARG1 == "log" ]; then                                    
    git.exe "$@" | more                                                 
  else                                                                  
    git.exe "$@"                                                        
  fi                                                                    
else                                                                    
  /usr/bin/git "$@"                                                     
fi                 

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

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

For those who’re interested in WSL’s disk IO perf challenges, you may be interested in @SvenGroot’s awesome writeup over in the main issue tracking disk perf issues (#873)

Is there an update ? Git seems like a pretty pivitol use case for WSL. Currrently, git is pretty much unusable on a windows filesystem.

Thanks everyone. Was facing this exact problem. the git.exe solution here is really good and give me back my performance. But getting ssh works with git was troubling me. so my solution is with putty’s pageant.

#!/bin/bash
# WSL 'git' wrapper, save as /usr/local/bin/git and chmod a+x

REALPATH=`readlink -f ${PWD}`
ARG1=$1

if [[ ${REALPATH:0:5} = "/c/"* ]] || [[ ${REALPATH:0:5} = "/d/"* ]] ; then
  export GIT_SSH="/path/to/plink.exe"
  export WSLENV="GIT_SSH/p"
  if [ $ARG1 == "log" ]; then
    git.exe "$@" | more
  else
    git.exe "$@"
  fi
else
  /usr/bin/git "$@"
fi

Just to put my 2-cents where it does not belong, I’m in complete agreement with @therealkenc in terms of real engineering budget needing to be allocated to WSL. What your team has done so far is amazing, but if WSL is intended to be a mechanism for wooing developers away from Macs/VMsfor their development environments, getting git, or for that matter any utilities that work on thousands of little files to perform well is key. Working on hundreds, thousands or millions of small-large files is de rigueur for programmers, analysts and sysadmins.

Giving the WSL team some funding/time/resources to be able really tackle the hard computing problems like disk I/O performance is essential to keeping WSL from becoming perceived as a half-hearted attempt to woo developers/sysadmins. It’s not yet, but this type of thing could be a subconscious litmus test for many.

@GenesisCraig If, as suggested, you take a look at #873 - the main issue tracking this problem - you’ll notice this comment from Sven Groot - the engineer responsible for much of WSL’s IO infrastructure.

We appreciate that WSL’s disk IO perf isn’t yet where we want it to be, but know that we’re working hard across several teams, deadlines, priorities, etc. to figure out some significant improvements.

Please bear with us.

@bmayen Bwaahhhahahh!

@therealkenc - If only that was the way big org’s worked 😉

@GenesisCraig - Appreciate your input, but as I (often) recommend, lets limit “pontification from the sidelines” esp. in relation to commentary on teams one is not involved with and/or have no knowledge of how said teams operate. If it was as simple as “throw a couple of devs at it”, the problem would be fixed by now.

Know that the team is painfully aware of these issues, and is working hard with several partner teams with the specialist knowledge, understanding, skills, and mandate to work on the relevant improvements in up-coming releases. We are passionately committed to resolve this issue given time to work through the highly complex changes required.

This is/was a core usage for me too. The talk about how the git.exe is able to have windows-specific file system optimizations definitely explains why it works so much better than the linux binary. The solution discussed in this thread almost does everything I need. I could never got the git log to actually pager/use less while in ConEmu - regardless of what git config --pager type of commands I tried 😃 If anyone else has figured that out, then I think the solution would be a viable work around in the mean time.

That said, after spending $7.5 billion dollars on github, this narrow ask could probably be fixed pretty quick with (I dunno) a ten or twenty million dollar engineering budget. Seems like rounding error to me. And what’s with the Mac peeps getting the good stuff before us, huh? 😉

gets worse when you using a prompt that updates based on your git status

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)