On Thursday 10 December 2015 01:26:38 Pádraig Brady wrote:
> I also noticed a lot of fcntl calls on XFS
> (basically one per file), which I need to look further into:
>   $ strace -c find/find /usr/share >/dev/null
>   % time     seconds  usecs/call     calls    errors syscall
>   ------ ----------- ----------- --------- --------- ----------------
>    40.03    0.147809           1    151710           fcntl
>    17.62    0.065069           1     63154           close
>    14.52    0.053608           1     40071           newfstatat
>    13.15    0.048547           1     35400           getdents

In my testing, fcntl() was called 8x for each directory traversed.

It was mainly caused by the implementation of opendirat().  It calls 
set_cloexec_flag(), which calls fcntl() two times.  Then it calls
fdopendir(), which also calls fcntl() two times.  fts_build() also
calls set_cloexec_flag().  Then inside_dir() calls dup_cloexec(),
which is fcntl (fd, F_DUPFD_CLOEXEC, 0).

Perhaps some syscalls could be optimized out by using dup_cloexec()
also in fts_build()?

Kamil

Reply via email to