From cf62e00295cbec7e61485f766321f6879620afc0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Koutn=C3=BD?= Date: Mon, 17 Feb 2025 15:40:24 +0100 Subject: [PATCH] path: Close inotify FD asynchronously MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- src/core/path.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { -- 2.47.3