bash - Why does Cygwin execute shell commands very slowly?

ID : 274389

viewed : 24

Tags : bashcygwinbash





Top 5 Answer for bash - Why does Cygwin execute shell commands very slowly?

vote vote

98

How about excluding Cygwin paths from your antivirus software ?

vote vote

89

Check your path. Referring a non-existant path or a very slow network share can cause the symptoms you are describing.

vote vote

78

Below are 3 possible causes which I encountered. Of course, other problems not mentioned can also cause slow shell commands in Cygwin.

  • If you have the option "Automatically detect settings" in "LAN Settings", Windows will use the WPAD protocol to discover the local HTTP proxy. First it will send a DHCP "Inform" request with option 252, then it will try a DNS lookup on "wpad". These 2 operations can take a few seconds to time-out.

  • If the shell accesses some paths like /cygdrive/... , a NetBIOS name query will be executed, which can also take some time to time out.

  • If the shell accesses some paths like //mypath/... , a NetBIOS name query will be executed, which can also take some time to time out.

Solutions :

  • Disable "Automatically detect settings" in "LAN Settings" in the Windows "Internet Options" control panel.

  • Add the following entry in %SystemRoot%\system32\drivers\etc\hosts :

127.0.0.1 localhost cygdrive wpad

  • Make sure to avoid double slashes at the beginning of all paths.
vote vote

68

Finally, I found the source - a service named "QQPCMgr RTP Service" running on my office computer, it's the real time protection service of "QQ PC Manager".

By disabling it, the time of the script in the question falls back to:

real    0m0.943s user    0m0.105s sys     0m0.231s 

I have told the developers of QQPCMgr about this, hope they will find the reason.

This still much slower than Linux, but gets the same "real time" of other cygwin computers.

Thank you all!

vote vote

58

This is how this problem manifested for me. For the first say 20 commands entered at the cygwin prompt it is fast, then it abruptly becomes painfully slow.

I checked that every item in my path was a valid directory.

I tried an authentication fix suggested elsewhere - https://superuser.com/questions/877051/cygwin-from-windows-very-slow-laggy/1247517 . It didn't work for me.

I replaced my exisitng virus scanner (System Center Endpoint Protection) with Sophos. That fixed the problem for me. Hope this helps.

Top 3 video Explaining bash - Why does Cygwin execute shell commands very slowly?







Related QUESTION?