On 2013-03-27, Adam Dinwoodie wrote: > Having bash-completion installed significantly slows down starting a new > Cygwin > Bash login shell. It's a problem I've noticed, and I've seen other users > report it on this list and elsewhere, too. I've done a bit of digging into > what the problem is, and what can be done about it-suggestions are at the > bottom of this email. > > The slow-down from using bash-completion is due to loading the contents of the > /etc/bash_completion.d/ directory. By adding `time` statements at various > ponits in /etc/bash_completion, I can see it's adding a fairly consistent > 6-6.5 > seconds to the shell startup time for me, which more-or-less matches my > subjective experience (starting Bash without bash-completion installed is > near-instant). > > Drilling down, there are 187 different scripts in my /etc/bash_completion.d > (which, until today, should have been untouched by anything other than Cygwin > setup.exe). Average load times for me vary from less than a millisecond to > over 600 milliseconds. I've attached my analysis as a CSV; times are as > reported by Bash's `time` builtin for the time for /etc/bash_completion to dot > in that script. > > A lot of the scripts are for things I don't have installed. The top four > scripts in terms of time taken (mailman, shadow, dsniff, e2fsprogs) do nothing > on my system, but between them alone add 1.5 seconds to the average Bash load > time. The top 4 seconds includes only two scripts I'm interested in (git and > gdb). > > On my PC, I've renamed the majority of the scripts in /etc/bash_completion.d > to > have a .bak extension, which prevents bash-completion from loading them. I've > kept 37 hand-selected scripts which I either do use or could forsee me using. > I'm now seeing Bash take less than a second to load, with picking up all the > scripts taking about 0.3 seconds. > > To avoid others suffering in the same way, I can think of a few different > options, none of which are ideal: > > - Add something to the Cygwin FAQ detailing a solution similar to the above. > Requires users to actively look for a solution, but requires minimal > effort. If people think this would be useful, I'm happy to draft > something > up. > > - Customize Cygwin's bash-completion package, removing scripts for functions > that don't exist in Cygwin. This is obviously additional work for the > package maintainer (although I'd be glad to help). This won't help for > packages that could be installed but aren't, however, but it's at least a > step. > > - Split out the bash-completion script into separate packages that users can > install as needed. I suspect this is far more effort than it's worth, > however, both for users and maintainers. > > - Something else yet to be suggested.
Cygwin's bash-completion package is version 1.3. Versions 1.9 and later use dynamic loading of completions that is supposed to improve the loading times. I think your best bet is to wait for the Cygwin package to be updated to the latest 2.1 version and see how that improves performance. Or just download and install it from source yourself. That said, I'm surprised by the variation in load times of the files in /etc/bash_completion.d that you observed. Those files all start with a call to the have() function which should abort further processing of the file if the corresponding program is not installed. Regards, Gary -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple