[20231130]快速删除大量文件测试(perl版本)3.txt
--//上上个星期做维护时,发现一台机器累积了大量aud文件,使用find -mtime +30 做保留1个月的删除操作时那个慢简直无法形容。
--//我做了一些测试,结果测试遇到一些问题或者疑惑,浪费大量时间,根据以前测试我知道perl对于这样的删除很快,我以前做个类似测
--//试。以下测试是在我多次测试后发现的规律或者总结。
1.建立测试环境:
$ mount | column | grep u01
/dev/cciss/c0d0p6 on /u01 type ext3 (rw)
--// /u01的文件系统是ext3.
--//按照顺序建立文件。
$ cd /u01/testrm
$ time for i in $(seq -f "%06g" 300000); do >| $i.aud; done
--//注:这样建立文件大小0字节,并不影响后面的测试结论。你可以修改echo test $i >| $i.aud.
--//顺便说一下使用touch $i.aud 建立文件很慢,我不知道为什么.
$ time perl -e 'unlink for ( )'
real 0m4.077s
user 0m0.445s
sys 0m2.961s
--//按照相反的顺序建立文件。
$ time for i in $(seq -f "%06g" 300000 -1 1 ); do >| $i.aud; done
$ time perl -e 'unlink for ( )'
real 0m4.625s
user 0m0.459s
sys 0m3.476s
--//你可以发现不论从顺序建立文件删除还是相反的顺序删除文件,perl删除全部文件的时间基本差不多。
2.乱序测试:
--//按照乱序建立文件,我不知道bash shell如何实现,我先通过oracle的sql语句建立乱序数字输出。
set pagesize 0
spool aa.txt
select lpad(level,6,'0') from dual connect by level | $i.aud; done
real 0m6.139s
user 0m1.917s
sys 0m3.602s
--//按照乱序建立文件
$ ls -f| head
.
..
026879.aud
078531.aud
084876.aud
034744.aud
280025.aud
063529.aud
137869.aud
163787.aud
--//ls -f 按照不排序输出ls的结果,注意这里的输出顺序,开始忘记记录这部分内容后面补充。
$ time perl -e 'unlink for ( )'
real 1m56.617s
user 0m0.582s
sys 0m7.562s
--//大约使用了2分钟,建立同样数量的文件,删除全部文件时时间存在巨大的差异。你可以从前面的测试得到一个结论,如果按照文件建立顺序或
--//者按照文件建立相反顺序删除,perl执行时间最短。
--//而乱序情况下perl删除全部文件需要的时间就很长。
$ time for i in $(cat aa.txt ); do >| $i.aud; done
real 0m6.426s
user 0m1.952s
sys 0m3.773s
--//按照乱序建立文件
--//如果按照建立文件顺序删除情况如何呢?
$ time sed "s/$/.aud/" aa.txt | xargs rm -f
real 0m5.848s
user 0m0.541s
sys 0m5.105s
$ time for i in $(cat aa.txt ); do >| $i.aud; done
real 0m6.142s
user 0m1.828s
sys 0m3.667s
$ sed "s/$/.aud/" aa.txt | head | xargs -IQ ls -il Q
307658760 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 140937.aud
307658761 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 240905.aud
307658762 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 270377.aud
307658763 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 193840.aud
307658764 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 246942.aud
307658765 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 293988.aud
307658766 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 108455.aud
307658767 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 191485.aud
307658768 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 139070.aud
307658769 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:43 252420.aud
--//注意看前面的inode号,从小到大递增。
$ time sed "s/$/.aud/" aa.txt | xargs rm -f
real 0m5.756s
user 0m0.567s
sys 0m5.002s
--//做了2次测试基本都是在6秒之内完成全部删除操作。
--//如果按照建立文件相反顺序删除情况如何呢?
$ time for i in $(cat aa.txt ); do >| $i.aud; done
..
$ sed "s/$/.aud/" aa.txt | tail | tac |xargs -IQ ls -il Q
240129000 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 100875.aud
240128999 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 222876.aud
240128998 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 146231.aud
240128997 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 088828.aud
240128996 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 288965.aud
240128995 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 279611.aud
240128994 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 021304.aud
240128993 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 137863.aud
240128992 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 000497.aud
240128991 -rw-r--r-- 1 oracle oinstall 0 Dec 1 08:53 138707.aud
--//注意看前面的inode号,从大到小递减。
$ time sed "s/$/.aud/" aa.txt | tac | xargs rm -f
real 0m6.924s
user 0m0.447s
sys 0m5.915s
--//到这里应该很容易猜测只要按着inode的大小顺序(反向也可以),删除操作很快完成,至于为什么我不知道。
3.继续探究:
--//按照顺序建立文件。
$ time for i in $(seq -f "%06g" 300000); do >| $i.aud; done
real 0m6.432s
user 0m2.108s
sys 0m3.730s
$ ls -f| head
.
..
026879.aud
078531.aud
084876.aud
034744.aud
280025.aud
063529.aud
137869.aud
163787.aud
--//注意这里的输出顺序与前面乱序建立的情况ls -f的输出完全一样,也就是可以看出建立文件时按照某种结构插入目录文件的,我估
--//计最大的可能是为了快速定位文件在目录的位置,具体的算法我不知道。
$ find /u01/testrm -name "*.aud" -type f -mtime 0 | head
/u01/testrm/026879.aud
/u01/testrm/078531.aud
/u01/testrm/084876.aud
/u01/testrm/034744.aud
/u01/testrm/280025.aud
/u01/testrm/063529.aud
/u01/testrm/137869.aud
/u01/testrm/163787.aud
/u01/testrm/111415.aud
/u01/testrm/177021.aud
--//find的输出顺序与ls -f的显示顺序一致。
4.使用strace跟踪看看:
$ strace -T -tt -o /tmp/yy1.txt perl -e 'unlink for ( )'
--//查看跟踪文件内容:
...
09:32:12.880118 open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 3
09:32:12.880192 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
09:32:12.880275 getdents(3, /* 1024 entries */, 32768) = 32752
--//开始读取目录
09:32:12.884932 lstat("026879.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.885034 lstat("078531.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.885127 lstat("084876.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.885215 lstat("034744.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.885308 lstat("280025.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.885393 lstat("063529.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
...
--//你可以发现perl delete的特点是getdents之后跟着lstat,注意看lstat里面的文件与前面的一样.
--//也就是建立文件插入目录时,linux似乎做了某种hash或者像oracle索引结构的设计,我估计为了查询文件名时加快寻找.
09:32:12.976026 getdents(3, /* 1024 entries */, 32768) = 32768
09:32:12.980519 lstat("121204.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.980617 lstat("006462.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.980704 lstat("235760.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.980791 lstat("187943.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.980880 lstat("235116.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.980967 lstat("077735.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:32:12.981056 lstat("126397.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
...
--//接着getdents之后跟着lstat,如此反复.
09:32:42.003591 brk(0x421d000) = 0x421d000
09:32:42.004063 unlink("000001.aud") = 0
09:32:42.004195 unlink("000002.aud") = 0
09:32:42.004240 unlink("000003.aud") = 0
09:32:42.004354 unlink("000004.aud") = 0
09:32:42.004440 unlink("000005.aud") = 0
09:32:42.004523 unlink("000006.aud") = 0
09:32:42.004565 unlink("000007.aud") = 0
09:32:42.004656 unlink("000008.aud") = 0
09:32:42.004697 unlink("000009.aud") = 0
09:32:42.004793 unlink("000010.aud") = 0
--//最后集中做unlink操作,注意看unlink的文件按照文件名顺序排序删除的,你可以测试反序建立文件也是按照这个顺序unlink。
--//这样删除文件最快,这也是perl为什么测试删除文件快的原因。只要按照文件名顺序建立或者反序建立,perl删除文件都是最快的。
--//补充实际上按照inode的顺序删除最快(反向类似)。
--//按照相反的顺序建立文件。
$ time for i in $(seq -f "%06g" 300000 -1 1 ); do >| $i.aud; done
real 0m6.564s
user 0m2.311s
sys 0m3.634s
$ ls -f | head
.
..
026879.aud
078531.aud
084876.aud
034744.aud
280025.aud
063529.aud
137869.aud
163787.aud
$ find /u01/testrm -name "*.aud" -type f -mtime 0 | head
/u01/testrm/026879.aud
/u01/testrm/078531.aud
/u01/testrm/084876.aud
/u01/testrm/034744.aud
/u01/testrm/280025.aud
/u01/testrm/063529.aud
/u01/testrm/137869.aud
/u01/testrm/163787.aud
/u01/testrm/111415.aud
/u01/testrm/177021.aud
--//与前面测试乱序建立的输出顺序一致。
--//采用find方式删除。
$ strace -T -tt -o /tmp/yy2.txt find /u01/testrm -name "*.aud" -type f -mtime 0 -delete
--//查看跟踪文件内容:
...
09:44:09.125396 lstat("testrm", {st_mode=S_IFDIR|0755, st_size=15110144, ...}) = 0
09:44:09.125482 open("testrm", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 4
09:44:09.125547 fcntl(4, F_SETFD, FD_CLOEXEC) = 0
09:44:09.125614 getdents(4, /* 1024 entries */, 32768) = 32752
09:44:09.130441 getdents(4, /* 1024 entries */, 32768) = 32768
09:44:09.135179 getdents(4, /* 1024 entries */, 32768) = 32768
09:44:09.139739 brk(0xfa2000) = 0xfa2000
09:44:09.140032 getdents(4, /* 1024 entries */, 32768) = 32768
09:44:09.144713 getdents(4, /* 1024 entries */, 32768) = 32768
09:44:09.149302 mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdbe36c5000
--//开始读取目录,find -delete 的特点是集中读取目录。
..
09:44:10.468072 open("testrm", O_RDONLY|O_NOFOLLOW) = 4
09:44:10.468156 fchdir(4) = 0
09:44:10.468220 close(4) = 0
09:44:10.468282 stat(".", {st_mode=S_IFDIR|0755, st_size=15110144, ...}) = 0
09:44:10.468404 lstat("026879.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:44:10.468501 unlink("026879.aud") = 0
09:44:10.468631 lstat("078531.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:44:10.468715 unlink("078531.aud") = 0
09:44:10.468807 lstat("084876.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:44:10.468892 unlink("084876.aud") = 0
09:44:10.468979 lstat("034744.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:44:10.469063 unlink("034744.aud") = 0
09:44:10.469152 lstat("280025.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
09:44:10.469235 unlink("280025.aud") = 0
09:44:10.469327 lstat("063529.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
...
--//你可以发现find -delete的特点是lstat,然后unlink,交替执行,并且删除时按照ls -f输出顺序删除的。这也是测试时为什么find 删
--//除很慢的原因。
5.如何加快find的删除操作,如果我find输出后按照建立顺序排序,就可以加快删除操作。
$ time for i in $(seq -f "%06g" 300000 -1 1 ); do >| $i.aud; done
real 0m7.151s
user 0m2.273s
sys 0m4.279s
$ time find /u01/testrm -name "*.aud" -type f -mtime 0 -delete
real 0m25.613s
user 0m0.235s
sys 0m5.051s
$ time for i in $(seq -f "%06g" 300000 ); do >| $i.aud; done
real 0m7.855s
user 0m2.393s
sys 0m4.845s
$ time find /u01/testrm -name "*.aud" -type f -mtime 0 -delete
real 0m37.125s
user 0m0.234s
sys 0m4.978s
--//正反顺序find删除差距还是很大的。但是比前面乱序建立时的perl删除要快(当时测试1m56.617s),不能简单的得出perl删除要快的结
--//论.
$ time for i in $(seq -f "%06g" 300000 -1 1 ); do >| $i.aud; done
real 0m3.978s
user 0m1.985s
sys 0m1.688s
$ time find /u01/testrm -name "*.aud" -type f -mtime 0 | sort | xargs rm -f
real 0m9.582s
user 0m2.634s
sys 0m6.518s
$ time for i in $(seq -f "%06g" 300000 ); do >| $i.aud; done
real 0m7.166s
user 0m2.191s
sys 0m4.324s
$ time find /u01/testrm -name "*.aud" -type f -mtime 0 | sort | xargs rm -f
real 0m9.381s
user 0m2.599s
sys 0m6.443s
--//我仅仅排序后做删除就可以提到3-4倍的执行效率。
$ time for i in $(seq -f "%06g" 300000 ); do >| $i.aud; done
real 0m7.157s
user 0m2.267s
sys 0m4.277s
$ time find /u01/testrm -name "*.aud" -type f -mtime 0 | sort -r | xargs rm -f
real 0m10.542s
user 0m2.696s
sys 0m7.458s
--//正反顺序find删除时间基本接近,包括sort -r 反向排序.
$ time for i in $(seq -f "%06g" 300000 -1 1 ); do >| $i.aud; done
real 0m6.505s
user 0m2.177s
sys 0m3.732s
$ ls -1| head
000001.aud
000002.aud
000003.aud
000004.aud
000005.aud
000006.aud
000007.aud
000008.aud
000009.aud
000010.aud
--//ls -1输出是按照文件名排序。注意:不能加入*.aud,否者报错。
$ ls -1 *.aud
-bash: /bin/ls: Argument list too long
$ time ls -1 | xargs rm -f
real 0m7.600s
user 0m1.078s
sys 0m6.059s
$ time for i in $(seq -f "%06g" 300000 -1 1 ); do >| $i.aud; done
real 0m6.357s
user 0m2.075s
sys 0m3.655s
$ ls -1r | head
300000.aud
299999.aud
299998.aud
299997.aud
299996.aud
299995.aud
299994.aud
299993.aud
299992.aud
299991.aud
--//ls -1r输出是按照文件名反序输出。
$ time ls -1r |xargs rm -f
real 0m7.071s
user 0m1.087s
sys 0m5.507s
--//两者删除文件的时间基本差不多。实际上find+sort操作需要2秒多一点,ls -1或者ls -1r少了这步,快一点点在这里。
$ time find /u01/testrm -name "*.aud" -type f -mtime 0 | sort > /dev/null
real 0m2.820s
user 0m2.318s
sys 0m0.515s
6.好了前面的测试已经很好的说明问题,只要按照文件建立的顺序正反序删除就可以很快完成删除操作,补充按照inode顺序也更准确一些。
--//回到oracle审计文件删除上来:
$ ls -f | head
.
..
orcl_ora_49229_20231117104957354906290008.aud
orcl_ora_49262_20231117104958479874669278.aud
orcl_ora_49599_20231117105130899183697083.aud
orcl_ora_52344_20231117105835514553538354.aud
orcl_ora_52379_20231117105836626306454092.aud
orcl_m002_6305_20231117110051062094812410.aud
orcl_ora_55493_20231117110714334874822725.aud
orcl_ora_55528_20231117110715482289829155.aud
--//oracle现在审计文件格式 实例名_ora_进程号_时间戳.aud.(秒后面有12位数字,有这么高的精度吗).
--//只要find输出时按照文件名的时间戳排序,在一定程度就可以加快删除操作。
$ find /u01/app/oracle/admin/orcl/adump -name "*.aud" -type f -mtime +42 | sort -t_ -k4 | head | xargs -IQ ls -i1 Q
154733506 /u01/app/oracle/admin/orcl/adump/orcl_m002_103732_20231017110035359232720142.aud
154733529 /u01/app/oracle/admin/orcl/adump/orcl_m004_110675_20231017120043480619698786.aud
154735804 /u01/app/oracle/admin/orcl/adump/orcl_ora_224151_20231017153647587216377199.aud
154735805 /u01/app/oracle/admin/orcl/adump/orcl_ora_224186_20231017153648713247889013.aud
154735806 /u01/app/oracle/admin/orcl/adump/orcl_ora_227253_20231017154511435652647386.aud
154735807 /u01/app/oracle/admin/orcl/adump/orcl_ora_227287_20231017154512551234098090.aud
154735810 /u01/app/oracle/admin/orcl/adump/orcl_ora_230283_20231017155335462649619544.aud
154735811 /u01/app/oracle/admin/orcl/adump/orcl_ora_230316_20231017155336584898000692.aud
154735812 /u01/app/oracle/admin/orcl/adump/orcl_ora_233425_20231017160201781015769289.aud
154735813 /u01/app/oracle/admin/orcl/adump/orcl_ora_233459_20231017160202911201216180.aud
$ find /u01/app/oracle/admin/orcl/adump -name "*.aud" -type f -mtime +42 | sort -t_ -k4 | tail | xargs -IQ ls -i1 Q
103842512 /u01/app/oracle/admin/orcl/adump/orcl_ora_77343_20231019084123230771453574.aud
103842515 /u01/app/oracle/admin/orcl/adump/orcl_ora_80356_20231019084948508678940025.aud
103860237 /u01/app/oracle/admin/orcl/adump/orcl_ora_80423_20231019084949696624114445.aud
103860242 /u01/app/oracle/admin/orcl/adump/orcl_ora_81719_20231019085609240478764069.aud
103860249 /u01/app/oracle/admin/orcl/adump/orcl_ora_83411_20231019085812371480121491.aud
103860250 /u01/app/oracle/admin/orcl/adump/orcl_ora_83476_20231019085813512882039706.aud
103860258 /u01/app/oracle/admin/orcl/adump/orcl_ora_84880_20231019090438453718991051.aud
103860259 /u01/app/oracle/admin/orcl/adump/orcl_ora_84918_20231019090442867110453317.aud
103860260 /u01/app/oracle/admin/orcl/adump/orcl_ora_86557_20231019090636659035246312.aud
103860273 /u01/app/oracle/admin/orcl/adump/orcl_ora_86593_20231019090637789105421979.aud
--//注意看inode的顺序,注意看tail的输出inode比head的输出要小,但是从局部讲还是按照顺序的。
$ find /u01/app/oracle/admin/orcl/adump -name "*.aud" -type f -mtime +42 | sort -t_ -k4 | xargs -IQ ls -i1 Q | less
...
154761643 /u01/app/oracle/admin/orcl/adump/orcl_ora_198568_20231018022435344923865006.aud
154761644 /u01/app/oracle/admin/orcl/adump/orcl_ora_198602_20231018022436473357263289.aud
--//这里出现不按照inode顺序排列输出的情况,inode满了吗。
70734765 /u01/app/oracle/admin/orcl/adump/orcl_ora_199728_20231018023001996661466789.aud
79132241 /u01/app/oracle/admin/orcl/adump/orcl_ora_199730_20231018023002033991270613.aud
...
--//具体删除操作不做了,现在看不出来区别。
7.一些补充说明:
--//我也尝试使用perl方式删除,因为我不能全部删除,必须保留一定的时间。我测试并不是很好,放弃。
--//链接 ,提到
--//方式是错误的。
/bin/perl -e 'unlink ( ) or die "Nothing deleted\n" ' >> ${REMOVAL_LOGFILE} 2>&1
--//它无法实现部分删除,而是全部删除!!
$ time for i in $(seq -f "%06g" 300000 -1 1 ); do >| $i.aud; done
real 0m6.980s
user 0m2.307s
sys 0m4.117s
$ time perl -e 'my $a=`find /u01/testrm -name "*.aud" -type f -mtime 0|sort`;unlink for ( );'
--//注意在| $i.aud; done
real 0m6.737s
user 0m2.190s
sys 0m3.932s
$ strace -T -tt -o /tmp/yy3.txt perl -e 'my @a=`find /u01/testrm -name "*.aud" -type f -mtime 0| sort`; unlink for ( );'
--//看出跟踪文件:
10:33:37.801543 ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffd30f53e0) = -1 EINVAL (Invalid argument)
10:33:37.801622 lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
10:33:37.801795 read(3, "/u01/testrm/000001.aud\n/u01/test"..., 4096) = 4096
10:33:40.683590 read(3, "01/testrm/000179.aud\n/u01/testrm"..., 4096) = 4096
10:33:40.683772 read(3, "/testrm/000357.aud\n/u01/testrm/0"..., 4096) = 4096
10:33:40.683898 brk(0x1d09000) = 0x1d09000
10:33:40.684020 read(3, "estrm/000535.aud\n/u01/testrm/000"..., 4096) = 4096
10:33:40.684174 read(3, "trm/000713.aud\n/u01/testrm/00071"..., 4096) = 4096
10:33:40.684377 read(3, "m/000891.aud\n/u01/testrm/000892."..., 4096) = 4096
10:33:40.684554 read(3, "001069.aud\n/u01/testrm/001070.au"..., 4096) = 4096
10:33:40.684714 read(3, "1247.aud\n/u01/testrm/001248.aud\n"..., 4096) = 4096
10:33:40.684780 brk(0x1d2a000) = 0x1d2a000
10:33:40.684827 brk(0x1d29000) = 0x1d29000
...
10:33:41.313614 close(3) = 0
10:33:41.313722 mmap(NULL, 7200768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f696b1c2000
10:33:41.317007 mmap(NULL, 7200768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f696aae4000
10:33:41.321387 munmap(0x7f696aae4000, 7200768) = 0
10:33:41.321670 brk(0x5238000) = 0x5238000
10:33:59.424916 brk(0x525e000) = 0x525e000
10:34:50.227654 brk(0x52de000) = 0x52de000
10:37:27.603509 brk(0x54de000) = 0x54de000
--//慢主要集中在这里。
10:39:07.427004 brk(0x54ff000) = 0x54ff000
10:39:07.427416 brk(0x5520000) = 0x5520000
10:39:07.427662 brk(0x5541000) = 0x5541000
10:39:07.428084 brk(0x5562000) = 0x5562000
10:39:07.428407 brk(0x5583000) = 0x5583000
10:39:07.428655 brk(0x55a4000) = 0x55a4000
....
10:39:07.530670 brk(0x727b000) = 0x727b000
10:39:07.555615 lstat("/u01/testrm/000001.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.564012 lstat("/u01/testrm/000002.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.564763 lstat("/u01/testrm/000003.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.565247 lstat("/u01/testrm/000004.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.565770 lstat("/u01/testrm/000005.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.566261 lstat("/u01/testrm/000006.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.566798 lstat("/u01/testrm/000007.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.567336 lstat("/u01/testrm/000008.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.567874 lstat("/u01/testrm/000009.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
10:39:07.568420 lstat("/u01/testrm/000010.aud", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
...
10:39:36.885909 brk(0x74cc000) = 0x74cc000
10:39:37.013522 unlink("/u01/testrm/000001.aud") = 0
10:39:37.013781 unlink("/u01/testrm/000002.aud") = 0
10:39:37.013880 unlink("/u01/testrm/000003.aud") = 0
10:39:37.013976 unlink("/u01/testrm/000004.aud") = 0
10:39:37.014070 unlink("/u01/testrm/000005.aud") = 0
10:39:37.014168 unlink("/u01/testrm/000006.aud") = 0
10:39:37.014260 unlink("/u01/testrm/000007.aud") = 0
10:39:37.014388 unlink("/u01/testrm/000008.aud") = 0
10:39:37.014483 unlink("/u01/testrm/000009.aud") = 0
10:39:37.014578 unlink("/u01/testrm/000010.aud") = 0
...
10:40:11.124497 unlink("/u01/testrm/299996.aud") = 0
10:40:11.124603 unlink("/u01/testrm/299997.aud") = 0
10:40:11.124711 unlink("/u01/testrm/299998.aud") = 0
10:40:11.124820 unlink("/u01/testrm/299999.aud") = 0
10:40:11.124927 unlink("/u01/testrm/300000.aud") = 0
10:40:11.258188 munmap(0x7f696bf7e000, 7200768) = 0
10:40:11.259021 munmap(0x7f696c65c000, 7200768) = 0
10:40:11.259749 munmap(0x7f696cd3a000, 2400256) = 0
10:40:11.260285 exit_group(0) = ?
8.总结:
--//如果你测试简单得到使用perl最快,那就犯了经验主义的错误,没有认真测试与分析,没有找到问题的本质.
--//最快的方式是按照文件建立的顺序删除或者反序删除操作效率最好,不在于使用perl还是其他命令.
--//更准确讲按照inode的顺序(不管正序还是反序),做删除操作效率最高。