[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: reading an empty directory after reboot is very slow

On Monday 13 April 2015 09:41:03 Vincent Lefevre wrote:
> On 2015-04-13 14:45:25 +0200, Loïc Grenié wrote:
> > 2015-04-13 14:39 GMT+02:00 Vincent Lefevre <vincent@vinc17.net>:
> > > The problem is that this operation is (always?) very slow:
> > > something like 100 seconds (1 minute and 40 seconds). It has been
> > > reproducible for several months. The logs show nothing during this
> > > operation.
> > >
> > > Any idea?
> >
> >     Maybe the directory is very large (even though its empty). Try
> >
> > ls -ld tmp.
> >
> >  and see if the file "tmp" is large.
> Thanks! I didn't know that (I thought that the file system would
> automatically "optimize" directories when files are removed, so
> I've never looked closely at their size). Indeed:
> ypig:~/eftests> ls -ld tmp
> drwxr-xr-x 2 vlefevre vlefevre 29655040 2015-04-13 15:25:55 tmp/

I wonder if our "sort" utilities also do that file shrink?

Unrelated of course, but of all the directory sorters I have written for 
a much smaller OS, one whose "dir" command presents you with an unsorted 
listing, we have dsort for cli use, and gsort for use when called by a 
gui button.  Both of these basically do a bubble sort on the directory, 
which in this examnple case is itself a file, with the output of the 
sort being re-written as the sorted list, with all the deleted entries 
removed, and the directory file itself truncated at the end of the last 
valid entry.  Otherwise, this file systems directories can grow quite 
large even if it does reuse the data slot occupied by a deleted file for 
a new file entry to conserve space.

If that is a solution and I've not a clue if it is, its something that 

A. Works "insitu" without all the hoorah of the cp and mv commands I saw 
previously in this thread.

And B. just as easily made into a crontab entry to be performed daily for 
instance.  One less bit of housekeeping YOU have to worry about.

I'll get me coat now...

Cheers, Gene Heskett
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

Reply to: