This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Zsh filename completion sluggishness?

On Thu, 13 Feb 2003, Jason Tiller wrote:

> Hi, Peter, :)

Hi Jason,

> Thanks muchly for your help with this!  Zsh seems to fit my temperment
> perfectly, if only I can work around issues. :)

I'm copying this to the list.  It's always better to have many eyes
looking at a problem :)

> On Thu, 13 Feb 2003, Peter A. Castro wrote:
> > On Thu, 13 Feb 2003, Jason Tiller wrote:
> > > However, Zsh seems painfully *slow*.  I'm using a recent Cygwin
> > > refresh (1.3.19-1) with Zsh-4.0.6-3, and the amount of time it
> > > takes Zsh to complete a directory name for 'cd', for example, is
> > > painful.  When I say it takes 2 seconds, that may not *seem* long,
> > > but when when I'm typing
> > > cd /q/de<tab>/neu<tab>/emt<tab>/co<tab>/hs
> > > and each of those <tab>s takes two seconds, I'm frustrated when I
> > > finally reach the end.
> > A dump of your env vars as well as any local vars you have set and
> > your zsh options might be insightful.
> I hope there's something in here that's useful to you - there's a
> heckuva LOT of it.  I apologize in advance for including it in here
> directly if that's bad etiquette.
> $ set > /dev/clipboard

I've edited your output to show just the interesting things :)

> FPATH=/usr/share/zsh/site-functions:/usr/share/zsh/4.0.6/functions
> PATH='.:/usr/bin:/c/WINNT/system32:/c/WINNT:/c/WINNT/System32/Wbem:/i/VCI/RTX SDK/bin:/i/Common Files/Adaptec Shared/System:/i/Rational/ClearCase/bin:/i/Rational/common:/i/Rational/ClearQuest:/c/BC5/BIN:/c/emacs-21.2/bin:/c/util:/c/emtprog:/c/j2sdk1.4.0_02/bin:/f/vc98/bin:/f/Common/MSDev98/Bin:/f/Common/Tools/WinNT:/f/Common/Tools'
> path=(. /usr/bin /c/WINNT/system32 /c/WINNT /c/WINNT/System32/Wbem '/i/VCI/RTX SDK/bin' '/i/Common Files/Adaptec Shared/System' /i/Rational/ClearCase/bin /i/Rational/common /i/Rational/ClearQuest /c/BC5/BIN /c/emacs-21.2/bin /c/util /c/emtprog /c/j2sdk1.4.0_02/bin /f/vc98/bin /f/Common/MSDev98/Bin /f/Common/Tools/WinNT /f/Common/Tools)

Well, your path doesn't look quite right.  Remove the quotes from the
directory paths.  Zsh doesn't like quotes embedded in the actual
directory names and it won't strip them off before using them.  If you
have a directory name which has a space (" ") in it, Make sure it's
correctly being specified.  You have two ways of setting your path.
Either via 'export PATH=' or 'set path=()'.  The syntax of the two is
different and you need to indicate that the directory with spaces is a
single object.  As a way of checking, type this after setting either
PATH or path:

$ for p in $path ; echo $p

If each complete directory path appears on a separate line, then it's
correct. Here's an example of mine:

$ for p in $path ; echo $p
/d/Program Files/Common Files/Real/Update

Next, is /i a mount point for a network shared drive or a local drive?
Is it really mount on /i or is /i a symlink?  Same question for /f
You might try replacing /i & /f with /cygdrive/i and /cygdrive/f.

> $ setopt > /dev/clipboard
> autocd
> cdablevars
> extendedglob
> interactive
> login
> monitor
> shinstdin
> zle

I have all of these set as well as others, so nothing strange here.

> > It might be interesting to know more about your machine's
> > configuration.  Speed of processor, main memory, version of Windows,
> > type of disk & interfaces, etc.
> Dell Latitude C600 laptop
> PIII 700MHz
> 256MB
> Win2K SP2
> 20GB ISA

Well, that beats my config, so no lack of horse-power.

> > > 18 13:47 /q/devtools/Neutrino/EmtPlus/vtest
> > > $ ls
> > > BAR      DIOPAT                         Ep        Per      tools
> > > BlueBox  DO                             HS        Summary  unittest
> > > Cfp      Das                            HW        Tst
> > > Com      Ddp                            IntgTest  UI
> > > DI       EMTPlus_descrepancy_table.doc  Lac       issues
> > >
> > > 19 13:47 /q/devtools/Neutrino/EmtPlus/vtest
> > > $ cd C<tab>
> > You example is more that just a simple file completion in your
> > current directory request.  The default key mapping for TAB is
> > expand-or-complete.  This goes through all the aliases, and the
> > files in all the paths in $PATH to try and pattern match against
> > your pattern of "C".
> I have very few aliases (none that I've created).  '.' is the first
> entry in the path.  Even if I have a terribly long PATH, shouldn't Zsh
> find an immediate match in the CWD?  Does it search along the *entire*
> PATH looking for a match, or does it take the first one it finds?

Zsh searches the entire PATH before displaying anything.

> > If you have quite a number of aliases or a hugh PATH, this could
> > create quite a bit of disk I/O, trying to match against ALL of those
> > files.  The file matching has permutations as well (like looking for
> > foo, foo.exe, foo.lnk and foo.exe.lnk) which adds extra stat calls
> > to try and feel out if there are special variant names Zsh should be
> > looking out for and offers them to the user.
> True, it seems as if the number of stat (or stat64 or lstat64) calls
> are high.

Well, that's the price one pays for the convenience that Zsh is providing :)

> > Try stripping your $PATH to
> > "/usr/bin:/usr/X11R6/bin:/usr/sbin:/sbin:."  and try your completion
> > again.
> I did this and didn't significantly impact the test case I had
> described above.  Note that I don't have any PATH entries that refer
> to NT shares.  The network overhead involved in the extra stat calls
> (/q is a Windows NT share) might have greatly outweighed any local
> lookups.  I'm guessing.

I have a few network shares set in my path and I'm not see the kind of
delays you are seeing. 

> > The sheer number of calls is a result of Zsh trying all the various
> > paths to resolve the pattern to a real name.
> It sounds like I want to find a way to reduce the number of paths that
> Zsh searches to try to match a file name.  Any suggestion on how I go
> about doing that?

Try rebinding tab to menu-complete:
$ bindkey "^I" menu-complete

> > On a typical unix system, these are system calls and are quite fast.
> > However, Cygwin is an emulation layer and thus there is extra
> > overhead to considder.  Considder what the performance impact is of
> > inserting an extra functional layer to for making a system call,
> > then multiply that by ALL the files Zsh looks up as well as all the
> > variants it trys too.
> I understand that, and I'm not surprised.  I think that Zsh is doing a
> heckuva lot more than bash is with my lowly <TAB> input.  Sounds like
> I should redefine <TAB> to do something simpler.  In my .inputrc for
> bash, I have
> TAB: menu-complete
> Something similar for Zsh would be appropriate.  My guess is that Zsh
> is trying to generate the list of completion options, and that's what
> necessitates that Zsh searches the entire path, slowing things down
> dramatically.

The problem is that it really shouldn't be slowing down that much.  I
have suggestion for you, which might help narrow things down, but it will
probably cost you an evening of experimenting.

First, rename all your .z* profiles in your home dir to something else so
they don't get loaded.  Open a "Command Prompt" (not a Cygwin Shell), and
set your NT PATH to have just the /c/WINNT directories in it
(/c/WINNT/system32 /WINNT).  Then, run Zsh manually with the "-l" option
(eg: "C:\path\to\cygwin\usr\bin\zsh.exe -l").  Check that your PATH in
Zsh is minimal (it should have just /usr/bin and a very few others in it
along with your /c/WINNT paths), then try doing a few name completions
for some of the Cygwin commands.  If this is speedy, then manually add a
few more of your old paths into $PATH and try again.  If it's not speedy,
manually remove one directory and try another completion.  This might
help narrow down which directory has the most overhead.  If, after adding
all paths back in, it's still speedy, then something that's being loaded
in one of your .z* profiles is causing a problem.  In which case, you'll
just have to try putting in a few lines of each at a time.  Start with
.zshenv, get through testing setting everthing in there first, then move
on to .zshrc, and finally .zlogin or .zprofile.  Again, do it in stages.

> Am I close to the mark?  Seems that "menu completion" without the list
> generation would be more appropriate.

See above concerning bindkey.  Doing an 'info zsh' will provide some good
bed-time reading :)

> Setting NO_AUTO_LIST and MENU_COMPLETE seems to help somewhat.  Local
> completion is much faster.  It seems to have had no effect on my NT
> share test, though (/q/dev<tab>/...).  Drat.

Well, give the above a go and let us know your results.

> Thanks again, Peter.  I think I'll just send this to you, unless you
> think the discussion would be useful in the Cygwin archives.  I'm also
> considering posting this to the Zsh Users list.  I haven't been on
> that list for long, so I'm not sure if it's an appropriate topic.

You can try posting to the general zsh users list (couldn't hurt).  I
suspect it's something to do with your environment and that's something
you'll just have to ferret out through careful elimination via trial and

> ---Jason

Peter A. Castro <> or <>
	"Cats are just autistic Dogs" -- Dr. Tony Attwood

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]