On 01/24/2018 09:17 PM, Peng Yu wrote:
$ time find -maxdepth 1 -name '*.tsv' > /dev/null
real 0m21.118s
user 0m0.446s
sys 0m0.577s
$ time find -name '*.tsv' > /dev/null
real 0m21.277s
user 0m0.454s
sys 0m0.636s
$ time ./main.sh > /dev/null
real 0m2.695s
user 0m0.046s
sys 0m0.057s
Is your find binary built with D_TYPE support?
$ find --version
find (GNU findutils) 4.6.0
Copyright (C) 2015 Free Software Foundation, Inc.
...
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD)
CBO(level=2)
____________________^^^^^^
Would you please try to reproduce this on a local file system, e.g. ext4?
Finally, use "strace -v find ..." so that we see whether the 'getdents'
system call returns D_TYPE information:
$ strace -ve getdents find -maxdepth 1 -name '*.tsv'
getdents(4, [{d_ino=4276237, d_off=4278742733963192100, d_reclen=24,
d_name=".", d_type=DT_DIR},
{d_ino=4055085, d_off=8511941719133486354, d_reclen=24,
d_name="..", d_type=DT_DIR},
{d_ino=4276239, d_off=9223372036854775807, d_reclen=24,
d_name="file", d_type=DT_REG}],
32768) = 72
getdents(4, [], 32768) = 0
In the end, it may turn out that either your 'find' binary is not compiled
with D_TYPE support, or that glusterfs doesn't provide this information
(and therefore find needs to invoke the additional newfstatat()s.
Have a nice day,
Berny