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.
This commit is contained in:
Michal Koutný
2025-03-04 21:37:58 +01:00
committed by Daan De Meyer
parent 52d5043b5e
commit cf62e00295
+2 -1
View File
@@ -5,6 +5,7 @@
#include <sys/inotify.h>
#include <unistd.h>
#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) {