From: Michal Koutný Date: Mon, 17 Feb 2025 14:40:24 +0000 (+0100) Subject: path: Close inotify FD asynchronously X-Git-Tag: v258-rc1~1188 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf62e00295cbec7e61485f766321f6879620afc0;p=thirdparty%2Fsystemd.git path: Close inotify FD asynchronously inotify FD may take several milliseconds to close. We measured daemon-reload default: (0.427 ± 0.05) s async: (0.323 ± 0.02) s with 5 path units out of 422 units. I.e. ~1% of units cause ~25% of delay, hence this fix seems like low-hanging fruit on the daemon-reload critical path. Particular inotify slowness pointed out by @fbuihuu. --- diff --git a/src/core/path.c b/src/core/path.c index c9ea31a74ea..4556dbfc71a 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -5,6 +5,7 @@ #include #include +#include "async.h" #include "bus-error.h" #include "bus-util.h" #include "dbus-path.h" @@ -169,7 +170,7 @@ void path_spec_unwatch(PathSpec *s) { assert(s); s->event_source = sd_event_source_disable_unref(s->event_source); - s->inotify_fd = safe_close(s->inotify_fd); + s->inotify_fd = asynchronous_close(s->inotify_fd); } int path_spec_fd_event(PathSpec *s, uint32_t revents) {