ls -l takes a forever to finish.

cpghost cpghost at
Wed Nov 28 08:25:53 PST 2007

On Wed, 28 Nov 2007 09:44:03 -0600
"Mark Evans" <mbe2 at> wrote:

> No we are not using NIS.
> it is a large directory i am listing.  actually it is the /usr/home 
> directory, and is probably the largest on the system. However "ls -l"
> runs for close to six minutesand spends the 10 seconds scrolling the
> screen with the results.  so i wait ls to start showing the results
> for about 5 and a half minutes.   Even on a older and much slower
> system i've never seen it talk more than 15 seconds to complete.

Does it run (much) faster with the -f flag or -lf flags?

I have a similar problem with *huge* directories: sorting them is
incredibly slow... though -l makes no difference; it's the sorting
itself than makes one think it is O(N^2) instead of O(N log N).

It could be a pathological case of Quicksort (ls(1) calls fts_open(),
which itself calls fts_sort() from /usr/src/lib/libc/gen/fts.c, and
that function calls qsort(3); so it's not entirely impossible...


Cordula's Web.

More information about the freebsd-questions mailing list