From owner-freebsd-questions@FreeBSD.ORG Fri Nov 30 12:40:59 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC0E116A474 for ; Fri, 30 Nov 2007 12:40:59 +0000 (UTC) (envelope-from bv@bilver.wjv.com) Received: from wjv.com (fl-65-40-24-38.sta.embarqhsd.net [65.40.24.38]) by mx1.freebsd.org (Postfix) with ESMTP id 5587213C4F2 for ; Fri, 30 Nov 2007 12:40:58 +0000 (UTC) (envelope-from bv@bilver.wjv.com) Received: from bilver.wjv.com (localhost.wjv.com [127.0.0.1]) by wjv.com (8.14.1/8.13.1) with ESMTP id lAUCeveN043345 for ; Fri, 30 Nov 2007 07:40:58 -0500 (EST) (envelope-from bv@bilver.wjv.com) Received: (from bv@localhost) by bilver.wjv.com (8.14.1/8.13.1/Submit) id lAUCeq1s043344 for freebsd-questions@freebsd.org; Fri, 30 Nov 2007 07:40:52 -0500 (EST) (envelope-from bv) Date: Fri, 30 Nov 2007 07:40:47 -0500 From: Bill Vermillion To: freebsd-questions@freebsd.org Message-ID: <20071130124047.GA42984@wjv.com> References: <20071130054906.B5CEC16A53E@hub.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071130054906.B5CEC16A53E@hub.freebsd.org> User-Agent: Mutt/1.4.2.2i Organization: W.J.Vermillion / Orlando - Winter Park ReplyTo: bv@wjv.com Subject: Re: ls -l takes a forever to finish X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bv@wjv.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Nov 2007 12:40:59 -0000 On Fri, Nov 30, 2007 at 05:49 , freebsd-questions-request@freebsd.org moved his mouse, rebooted for the change to take effect, and then said: > Date: Thu, 29 Nov 2007 08:42:44 -0500 > From: Bill Moran > Subject: Re: ls -l takes a forever to finish. > In response to Wojciech Puchar : > > > 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. There is a way to recreate the directory tree >without< having to use up a lot of free space. I used to do this when (in the old days) I was running a news node and some hierarchies would get so so large that directory access would be very slow even after the expire because the directory was so huge. Read the man page for cpio and use the -pdlmv option. This will create a new directory tree using ONLY links, so that you have done nothing except make a directory and have moved NO files at all. Then you can remove all the files in the original directory, returning the link count on each file to 1, and have an optimized directory that has all the files of the original. And if I recall correctly it will act like the tar utility where all the sub-directories will be in the first of each directory, thus reducing search time. I have >not< used the GNU version of this but used it all the time on SysV based systems I maintained - but it should be the same [however I have noticed that sometimes GNU based things have subtle changes at times]. > 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. Try the above sometime >>IF EVERYTHING IS ON THE SAME FILE SYSTEM<< and prepare to be amazed. It's fast. > -- > Bill Moran > http://www.potentialtech.com Bill -- Bill Vermillion - bv @ wjv . com