Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 3.1.2 beta bug



Zoltan Hidvegi wrote:
>As an experiment, 3.1.2 has leaf optimization.  It is assumed that a
>directory has no subdirectories if a directory has a link count less than
>2.  This optimization is also used by GNU find as I know.  Too bad that
>it does not work, since it can speed up some searches a lot (especially
>**/file type pattern globs).

find has an option "-noleaf" to disable the optimisation.  Perhaps we
need a similar option in zsh?

>                              Maybe a test for nlink == 2 instead of <= 2
>would help.  A filesystem without the usual Unix directory link count
>semantics would probably have link count 1 for directories.

No, not really.  Under Linux:

% ls -ld /proc /proc/*(/)
dr-xr-xr-x   5 root     root            0 Apr 30 22:29 /proc
dr-xr-xr-x   3 root     root            0 Jul 22 09:27 /proc/1
dr-xr-xr-x   3 root     root            0 Jul 22 09:27 /proc/11688
dr-xr-xr-x   3 root     root            0 Jul 22 09:27 /proc/12
dr-xr-xr-x   3 root     root            0 Jul 22 09:27 /proc/13
[many other processes]
dr-xr-xr-x   2 root     root            0 Jul 22 08:44 /proc/net
dr-xr-xr-x   2 root     root            0 Jul 22 09:27 /proc/scsi
dr-xr-xr-x   5 root     root            0 Jul 22 09:27 /proc/sys

The link count of 5 on /proc suggests three subdirectories, whereas it
actually has many more.  Even if zsh isn't doing that form of leaf
optimisation, the fact remains that a directory can easily have a
meaningful but wrong link count.  Not to mention the possibility of
a directory actually having multiple links other than . and .. (more
useful than one might imagine).

Leaf optimisation, though powerful, is of use in such limited
circumstances that it is almost useless.

-zefram



Messages sorted by: Reverse Date, Date, Thread, Author