Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Nov 2007 08:42:44 -0500
From:      Bill Moran <wmoran@potentialtech.com>
To:        Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>
Cc:        questions@freebsd.org, Mark Evans <mbe2@bayou.com>
Subject:   Re: ls -l takes a forever to finish.
Message-ID:  <20071129084244.eaba6f7a.wmoran@potentialtech.com>
In-Reply-To: <20071129122043.A9040@wojtek.tensor.gdynia.pl>
References:  <005901c8313f$f7048b70$0d00a8c0@bayoucshaffer> <474CA49D.50306@FreeBSD.org> <002001c831d5$80ad8670$0d00a8c0@bayoucshaffer> <a969fbd10711280752v7d38070x5f34d9d652ec4f7f@mail.gmail.com> <003101c831da$a405bc50$0d00a8c0@bayoucshaffer> <20071129122043.A9040@wojtek.tensor.gdynia.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
In response to Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>:

> > ls | wc
> 
> strange. i did
> 
> [wojtek@wojtek ~/b]$ a=0;while [ $a -lt 10000 ];do mkdir $a;a=$[a+1];done
> 
> completed <25 seconds on 1Ghz CPU
> 
> ls takes 0.1 seconds user time, ls -l takes 0.3 second user time.
> 
> unless you have 486/33 or slower system there is something wrong.

Another possible scenario is that the directory is badly fragmented.
Unless something has changed since I last researched this (which is
possible) FreeBSD doesn't manage directory fragmentation during use.
If you're constantly adding and removing files, it's possible that
the directory entry is such a mess that it takes ls a long time to
process it.

Of course, Wojciech's test won't demonstrate this, as the directory is
freshly created, even to the point that the filenames are actually in
alpha order in the directory.

One method to test this would be to tar up the directory and extract
it somewhere else on the machine (assuming you have enough space to do
so).  If the newly created directory doesn't have the problem, it's
likely that the directory entry has become a mess.  Use ls -l to
compare the sizes of the actual directories themselves as a little
exercise.

Anyway, if that turns out to be the problem, you can fix it by taring
the directory and then restoring it from the tarfile.  Not an ideal
solution, mind you.

-- 
Bill Moran
http://www.potentialtech.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071129084244.eaba6f7a.wmoran>