URL: <http://savannah.gnu.org/bugs/?48169>
Summary: find makes unnecessary syscalls Project: findutils Submitted by: None Submitted on: Wed 08 Jun 2016 01:10:23 AM UTC Category: find Severity: 3 - Normal Item Group: None Status: None Privacy: Public Assigned to: None Originator Name: Tavian Barnes Originator Email: taviana...@tavianator.com Open/Closed: Open Discussion Lock: Any Release: 4.6.0 Fixed Release: None _______________________________________________________ Details: $ mkdir -p foo/bar/baz $ strace find foo >/dev/null ... newfstatat(5, "bar", {st_mode=S_IFDIR|0755, st_size=6, ...}, AT_SYMLINK_NOFOLLOW) = 0 fcntl(5, F_DUPFD_CLOEXEC, 0) = 4 openat(5, "bar", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = 6 fcntl(6, F_GETFD) = 0 fcntl(6, F_SETFD, FD_CLOEXEC) = 0 fstat(6, {st_mode=S_IFDIR|0755, st_size=6, ...}) = 0 fcntl(6, F_GETFL) = 0x38800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_NOFOLLOW) fcntl(6, F_SETFD, FD_CLOEXEC) = 0 newfstatat(5, "bar", {st_mode=S_IFDIR|0755, st_size=6, ...}, AT_SYMLINK_NOFOLLOW) = 0 fcntl(6, F_DUPFD, 3) = 7 fcntl(7, F_GETFD) = 0 fcntl(7, F_SETFD, FD_CLOEXEC) = 0 getdents(6, /* 3 entries */, 32768) = 72 getdents(6, /* 0 entries */, 32768) = 0 close(6) = 0 newfstatat(7, "baz", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0 close(4) = 0 ... In particular: - fd 4 is unused - fcntl(6, F_SETFD, FD_CLOEXEC) happens twice, but could be totally avoided with O_CLOEXEC (I suspect the second one is from within fdopendir() though) - newfstatat(5, "bar", AT_SYMLINK_NOFOLLOW) happens twice - fcntl(7, F_SETFD, FD_CLOEXEC) could be avoided if fcntl(6, F_DUPFD_CLOEXEC) were used This seems new with 4.6, at least 4.4 didn't do this. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?48169> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/