Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cygwin commands from CMD are slow; from bash are fast

Tags:

windows

cygwin

I have been using Cygwin commands from my Windows CMD prompt for several months without problems. Within the past few days, every time I call a Cygwin command (ls for example), the command takes several seconds to "load" before it actually runs. If I try the same command from within a bash prompt, it runs ("loads") immediately.

The Cygwin FAQ mentions that network drives in PATH may cause problems, so I've tried some permutations of my PATH variable and network connectivity. Below, "full PATH" means my original path setting; "short PATH" means the path with only the Cygwin bin directory. Times are reported through the time command.

Timing results for ls

Connected to network:

  • Run ls within bash: 0.124 s
  • Run ls within CMD (full PATH): 41.29 s
  • Run ls within CMD (short PATH): 38.56 s

Disconnected from network:

  • Run ls within bash: 0.125 s
  • Run ls within CMD (full PATH): 0.17 s
  • Run ls within CMD (short PATH): 0.19 s

Results for cygcheck

I ran cygcheck -s and noticed:

Warning: There are multiple cygwin1.dlls on your path

although this may be due to running cygcheck from within Cygwin's bin directory. I completely uninstalled and reinstalled Cygwin and still see the same issue.

Results from netstat

I ran netstat -a -n before executing Cygwin's ls and after execution (while it is stalled). I did this several times and found one line from each run that appeared consistently during the delay:

  UDP    127.0.0.1:55030        *:*                    

The port number changed from test to test.

strace results

I ran Cygwin's strace on the ls command. Most of the delay is spent in calls such as:

11685  886560 [main] ls 10020 pwdgrp::fetch_account_from_windows: line: <xxxx>

and

12684  899244 [main] ls 10020 cyg_ldap::fetch_ad_account: No entry for (objectSid=\00\00\00\00) in xxxx DC=xxxx,DC=xxxx,DC=xxxx
like image 868
tbhartman Avatar asked Feb 13 '15 19:02

tbhartman


People also ask

How can I make Cygwin faster?

Trim down your Windows PATH (to the bare bones like %SystemRoot%\system32;%SystemRoot%) Remove things you don't need from bashrc and bash_profile. Move things you only need in your terminal window from bashrc to bash_profile. One surprisingly large time suck in Cygwin is Bash completion.

Is Cygwin slow?

Due to limitations of Windows and the NT kernel, Cygwin is often a lot slower than Linux when running, and one particular slowdown is due to the complex way Cygwin has to emulate the Linux fork() call.

How do I stop Cygwin from running?

Use -f to terminate native Windows processes not started by Cygwin processes. -f can also be useful to terminate Cygwin processes not answering to SIGKILL. Unless you specific the -W option, the "pid" values used by kill are the Cygwin pids, not the Windows pids.


1 Answers

A section in Cygwin's FAQ addresses slow startup times. Cygwin recently changed to using Active Directory lookups for authentication, rather than using flat files. Changing the defaults in /etc/nsswitch.conf from

passwd:   files db
group:    files db

to

passwd:   files
group:    files

skips the AD lookup. My Cygwin commands are now speedy again.

like image 50
tbhartman Avatar answered Sep 27 '22 17:09

tbhartman