Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- From: ewaguespack@xxxxxxxxx
- Date: 17 Jul 2006 09:30:12 -0700
xhoster@xxxxxxxxx wrote:
ewaguespack@xxxxxxxxx wrote:
i had a situation that required that i remove several thousand zero
byte files, and i tried this first:
# find . -type f -exec rm -f {} \;
this was taking ages, so on a hunch I decided to try this to see it I
got any better results:
That fires up a separate rm process for each file. Using strace -f, it
looks like this involves 99 system calls per rm (not counting the ones done
in the parent process), only one of which is related to the actual unlink.
# perl -e 'unlink(glob("*"))'
This doesn't do the -type f checking. If you don't really need to
do the -type f checking, why did you use find (rather than "rm -f *")
in the first place? One possible reason is if that gives you an argument
list too long error. I use the perl -le 'unlink(glob($ARGV[0]))' construct
frequently for just that reason.
surprisingly the perl unlink took about a quarter of a second to remove
1000 files versus 30 seconds with find / rm
That really surprises me. Not because of the difference between the two
methods, but because both of them are about 20 times slower for you than
they are on my not-particularly fast machine.
Xho
I used find because the original number of files would not delete using
rm -f *, i got the "argument list is too long" error
i think part of the problem is that the server in question was
experiencing high iowait times....
when I ran the rm command on an idle server it was much faster.
I am still curious why it was so much faster.
.
- Follow-Ups:
- References:
- why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- From: ewaguespack
- Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- From: xhoster
- why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Prev by Date: Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Next by Date: Re: Perl equivalent of this script?
- Previous by thread: Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Next by thread: Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Index(es):
Relevant Pages
|
|