Running git commands on Debian & Ubuntu on WSL is really slow for large projects

MortenMoulder picture MortenMoulder · May 8, 2018 · Viewed 7.4k times · Source

We have a very large project with almost 15.000 commits total. I run Debian 9.3 on my Windows machine using WSL. My git version is 2.17.0.

When I run commands such as git status, it takes at least 20 seconds to complete. Even if no changes were made.

I have tried multiple older versions of git and even tried Ubuntu, but I still experience the same result. I've tried running a bunch of commands from various posts on here and on other sites, but none of them worked.

Funny thing: When I open up cmd.exe or Git Bash on Windows, it takes less than a second to run git status.

What could be causing this? What can I do to fix this?

Answer

VonC picture VonC · May 18, 2018

Update June 2019: WSL 2 is coming, and with it a full system call compatibility.
That should increase Git command performance considerably!


Original answer 2018:

Git is working best when executed on a host without any intermediate layer.

For instance, if your repo is on a shared folder, Git would be considerably slower.
In case of WSL, the repo is locally accessed, but through through a filesystem translation between various Linux file system operations into NT kernel operations.

translation

That would be enough to explain degraded performance, especially on large Git repositories Plus make sure your $PATH does not reference folders with Windows executable that might be called instead of the Linux ones

Possible causes:

  • filesystem emulation (slow): WSL issue 2759
  • Shell Prompt: make sure to test your command in a basic shell prompt, without any complex PS1 computation
  • Windows Defender AV: try and exclude (for testing) the WSL-managed filesystem from AV scan.