4.2.

Starting a new terminal window is slow. What's going on?

There are many possible causes for this. This answer is more a list of things to look into than a set of solutions.

If your terminal windows suddenly began starting slowly after a Cygwin upgrade, it may indicate issues in the authentication setup.

For almost all its lifetime, Cygwin has used Unix-like /etc/passwd and /etc/group files to mirror the contents of the Windows SAM and AD databases. Although these files can still be used, since Cygwin 1.7.34, new installations now use the SAM/AD databases directly.

To switch to the new method, move these two files out of the way and restart the Cygwin terminal. That runs Cygwin in its new default mode. If you are on a system that isn't using AD domain logins, this makes Cygwin use the native Windows SAM database directly, which may be faster than the old method involving /etc/passwd and such. At worst, it will only be a bit slower. (Which situation applies depends on the benchmark you run.)

The 1.7.35 release is expected to bring improvements in the area by limiting the number of cases in which DC is contacted in default setup, but it will also limit the potential of the new integration scheme. I.e. Cygwin will not try to lookup your home directory or default shell from AD/SAM. For that, you will need to alter /etc/nsswitch.conf to suit your needs.

However, if you are still experiencing very slow shell startups, see below for a list of things to try to make startup times more manageable.

  1. For AD client systems: common cause of slow Cygwin Terminal startups is a bad DNS setup. Many things that occur during a Cygwin Terminal startup require fast DNS lookups. This is something for AD administrators to look into.

    This may affect both local and remote domain controllers.

  2. Another cause for AD client system is slow DC replies, commonly observed in configurations with remote DC access. Cygwin Terminal queries information about every group you're in to populate local cache. You may speed up this process a little by caching your own information in local files. Run this code in a terminal with write access to /etc:

    getent passwd $(id -u) > /etc/passwd
    getent group $(id -G) > /etc/group

    And set /etc/nsswitch.conf as follows:

    passwd: files db
    group:  files db

    This will limit the need for Cygwin to contact DC, while still allowing for additional information to be retrieved from DC, when f.e. listing remote directories.

  3. As an alternative, or to further speed up the slow DC resolution/answers, consider running cygserver as local caching module.

    Every new Cygwin process tree will check with cygserver before trying to address DC directly.

  4. Less preferable, but possible solution would be to create permanent cache of the authentication data in an old-fashioned way. To do this, re-run mkpasswd and mkgroup, then put the following into /etc/nsswitch.conf to make Cygwin treat these files as read-only local caches of your AD database:

    passwd: files
    group:  files

    By leaving out the "db" option, we are telling the Cygwin DLL not to even try to do AD lookups. If your AD servers are slow, this local cache will speed things up. The downside is the old stale cache problem: any time the AD databases change, your local cache will go out of date until you update the files manually.

If none of the above helps, the best troubleshooting method is to run your startup scripts in debug mode. Right-click your Cygwin Terminal icon, go to Properties, and edit the command. It should be something like C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -. Assuming you are using Bash for your login shell, change it to C:\cygwin64\bin\mintty /bin/bash -lx. That will cause it to write out a line for every command it runs. A slow Cygwin Terminal launch usually means one or more of the many commands Cygwin runs when starting up will take a long time. That will be your clue as to what's going on.