对于所有Cygwin应用程序,启动速度确实很慢 [英] Startup is really slow for all Cygwin applications
问题描述
在Windows 8.1 x64上启动任何Cygwin应用程序都需要一分钟以上。没关系,我是从快捷方式启动 mintty
还是从 cygwin.bat
或 ls.exe
或 bash.exe
。他们每个人都会很慢。
开始Bash或Minty之后,它们的工作速度很快:
$ i在{1..10}中的时间;做bash -c echo Hello;完成
你好
...
你好
真实0m1.273s
用户0m0.060s
sys 0m1.181s
我尝试过的步骤:
- 重新安装并尝试了Cygwin和Cygwin64几次(版本2.864)
- 以管理员身份启动了它们
- 试图在它们中运行它们Windows 7兼容模式
- 禁用LAN 文件以获取本地凭据或缓存的凭据,因此无需cygserver即可更快地运行。但是还没有运气。
Start of any Cygwin application takes more than a minute on Windows 8.1 x64. It doesn't matter, either I'm starting
mintty
from shortcut orcygwin.bat
orls.exe
orbash.exe
from bin folder. Each of them will be slow.After Bash or mintty is started they are working fairly quick:
$ time for i in {1..10} ; do bash -c "echo Hello" ; done Hello ... Hello real 0m1.273s user 0m0.060s sys 0m1.181s
Steps, which I've tried:
- Reinstalled and tried both Cygwin and Cygwin64 a few times (version 2.864)
- Started them as Administrator
- Tried to run them in Windows 7 compatibility mode
- Disabled "Automatically detect settings" for LAN as in this reply
- Added
127.0.0.1 localhost cygdrive wpad
to hosts as in same reply - Set antivirus to disabled state
- Checked that Bash completion is not installed (no
/etc/bash_completion.d
folder) - Disabled all removable drives in Device Manager (only system SSD and data HDD left)
- Tried to run with empty
etc/profile.d
folder - Tried to run with empty
etc/bash.bashrc
file
How else can I find root cause?
P.S. - I have two different systems, laptop and desktop both with Windows 8.1 64 bit. This issue it 100% reproducible on both.
Also, if I start Bash a few seconds after login it starts immediately.
解决方案Eventually I found what causes this issue, but I'm still not sure why. Cygwin works for other people in same environment very well.
Cause: On the start of every Cygwin application it tries to get credentials as it is described in
etc/nsswitch.conf
file. For some reason, it takes a lots of time for my account as it contacts with several Active Directory domain controllers via LDAP.Solution 1: You can save the current user and group in
etc/passwd
andetc/group
files and set Cygwin to check them before Active Directory.- Start
mintty.exe
and wait till it opens - Run
mkpasswd -c
and save its output toetc/passwd
file (you will have to create it, output should be one line) - Run
mkgroup -c
and save its output toetc/group
file (you will have to create it, output should be one line) - Open
etc/nsswitch.conf
and write
nsswitch.conf contents:
passwd: files # db group: files # db
Now your Cygwin should start immediately.
Solution 2: There is special CygServer application, shipped with Cygwin, which can be started as an NT service or as a simple process (just run
usr/sbin/cygserver.exe
). It caches credentials and propagates them to every next Cygwin process while cygserver is running.Add it to startup or start it before your Cygwin session and you're good — cygserver startup will take time, but every next Cygwin process will start immediately.
Is it your case? I want to share my investigation steps, so you could check, if your case is same to mine.
- Install MS Network Monitor as it is able to show traffic from a specific process. Run it as administrator.
- Create New capture tab and click Start (you don't have to add any filters or anything).
- Start
mintty
and you will see its connections in netmon: - You will see list of
mintty
connections in the tree view on the left and TCP and LDAP frames on the right after selecting on of those connections. - Additionally, you can get name of those remote machines by IP address. Run
nbtstat -a 8.8.8.8
in command line (replace 8.8.8.8 by one of IP addresses from netmon).
Going deeper: I'm still playing with etc/nsswitch.conf file to get local credentials or maybe cached ones so it will run faster without cygserver. But no luck yet.
这篇关于对于所有Cygwin应用程序,启动速度确实很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!