Why does Cygwin execute shell commands very slowly?

前端 未结 11 1157
说谎
说谎 2020-12-08 11:29

Just tests a very simple command like:

while true; do bash -c \"echo hello\"; done

You will find how much slow the bash in Cygwin is. Does

11条回答
  •  Happy的楠姐
    2020-12-08 11:52

    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.

提交回复
热议问题