[Leaplist] directory "size", does it matter?
tonyb at abcc.linuxceptional.com
tonyb at abcc.linuxceptional.com
Wed Jan 21 15:14:24 EST 2009
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
Cheers,
Tony
Ingo Claro wrote:
> Hello all:
> I've got a basic question:
> I know that a directory is just another file and it stores information
> regarding it's contents, so how does this directory size affect
> performance?
> for example if I have a directory with many file movements
> (create/delete) over time I've got this:
> drwxr-x--- 2 miclaro miclaro 9678848 Jan 20 20:53 tmp
>
> and there are no files inside.
> So it would be better to re-create this directory to reset the size? or
> it doesn't matter?
>
> regards,
> Ingo Claro
>
More information about the Leaplist
mailing list