[Leaplist] directory "size", does it matter?

Justin M. Keyes justinkz at gmail.com
Thu Jan 22 10:45:39 EST 2009


On Wed, Jan 21, 2009 at 3:14 PM,  <tonyb at abcc.linuxceptional.com> wrote:
> The number of blocks allocated to the directory have been increased because
> of the number of files that you have created within the directory.  The next
> time you go to create a large number of files the performance would be
> increased because the directory blocks would already be allocated.  Running
> a time on this script confirms my statement, albeit a very small increase.
>
> tonyb at church:/tmp> cat createTest
> #!/bin/bash
> mkdir -p zdir
> cd zdir
>
> for a in 0 1 2 3 4 5 6 7 8 9
> do
>  for b in 0 1 2 3 4 5 6 7 8 9
>  do
>    for c in 0 1 2 3 4 5 6 7 8 9
>    do
>      for d in 0 1 2 3 4 5 6 7 8 9
>      do
>        touch $a$b$c$d
>      done
>    done
>  done
> done
> exit
>
> #### Now to run the test, removing the directory when done.
>
> tonyb at church:/tmp> time ./createTest
>
> real    0m27.024s
> user    0m4.520s
> sys     0m14.509s
>
> tonyb at church:/tmp> \rm -rf zdir
> tonyb at church:/tmp> time ./createTest
>
> real    0m27.078s
> user    0m4.344s
> sys     0m14.537s
> tonyb at church:/tmp> \rm -rf zdir
> tonyb at church:/tmp> time ./createTest
>
> real    0m26.950s
> user    0m4.036s
> sys     0m14.537s
>
> ####### Note that in this test only file files are removed;
> ####### The directory remains.
>
> tonyb at church:/tmp> \rm  zdir/*
> tonyb at church:/tmp> time ./createTest
>
> real    0m26.786s
> user    0m4.204s
> sys     0m14.533s
> tonyb at church:/tmp> \rm  zdir/*
> tonyb at church:/tmp> time ./createTest
>
> real    0m26.721s
> user    0m4.232s
> sys     0m14.281s
>
> tonyb at church:/tmp> \rm  zdir/*
> tonyb at church:/tmp> time ./createTest
>
> real    0m26.772s
> user    0m4.536s
> sys     0m14.389s

i learned something today! i assumed directories were always listed as 4k...

Ingo, your curiosity has earned you a place on the terrorist watch-list!

Justin M. Keyes

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the Leaplist mailing list