git/compat/fsmonitor
Tamir Duberstein 08b12d90cd fsmonitor: flush pending FSEvents before cookie wait
56cef9cb1a (fsmonitor: use pthread_cond_timedwait for cookie wait,
2026-04-15) limits the cookie wait to one second so that a filesystem
which never delivers events cannot hang fsmonitor clients. A client that
times out receives a trivial response and scans the entire index.

FSEvents can defer delivery while it batches notifications and does not
guarantee that its queue is drained in one latency interval. A loaded
macOS system can therefore time out even though the event stream is
working.

On an Apple M4 Max (16 cores, 128 GiB RAM) running macOS 26.5.2, two
worktrees with a 1,001,178-entry index timed out 484 of 545 and 297 of
365 fsmonitor requests. One status call performed 934,519 lstat() calls
during a 47-second preload and took 52 seconds overall.

Ask FSEvents to flush pending notifications after creating the cookie
and before starting the timed wait. Use the asynchronous form because
the client handler holds main_lock, which the listener callback also
acquires. Keep the timeout and the behavior of the other backends
unchanged.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-07-22 12:26:41 -07:00
..
fsm-darwin-gcc.h fsmonitor: flush pending FSEvents before cookie wait 2026-07-22 12:26:41 -07:00
fsm-health-darwin.c fsmonitor: mark unused parameters in stub functions 2023-09-18 15:56:15 -07:00
fsm-health-linux.c fsmonitor: implement filesystem change listener for Linux 2026-04-15 08:44:33 -07:00
fsm-health-win32.c fsmonitor--daemon.h: remove unnecessary includes 2023-12-26 12:04:32 -08:00
fsm-health.h fsmonitor--daemon: stub in health thread 2022-05-26 15:59:27 -07:00
fsm-ipc-unix.c fsmonitor: rename fsm-ipc-darwin.c to fsm-ipc-unix.c 2026-04-15 08:44:33 -07:00
fsm-ipc-win32.c fsmonitor: prefer repo_git_path() to git_pathdup() 2023-09-18 15:56:14 -07:00
fsm-listen-darwin.c fsmonitor: flush pending FSEvents before cookie wait 2026-07-22 12:26:41 -07:00
fsm-listen-linux.c fsmonitor: flush pending FSEvents before cookie wait 2026-07-22 12:26:41 -07:00
fsm-listen-win32.c fsmonitor: flush pending FSEvents before cookie wait 2026-07-22 12:26:41 -07:00
fsm-listen.h fsmonitor: flush pending FSEvents before cookie wait 2026-07-22 12:26:41 -07:00
fsm-path-utils-darwin.c fsmonitor-ll.h: split this header out of fsmonitor.h 2023-06-21 13:39:54 -07:00
fsm-path-utils-linux.c fsmonitor: implement filesystem change listener for Linux 2026-04-15 08:44:33 -07:00
fsm-path-utils-win32.c fsmonitor: mark unused parameters in stub functions 2023-09-18 15:56:15 -07:00
fsm-settings-unix.c fsmonitor: rename fsm-settings-darwin.c to fsm-settings-unix.c 2026-04-15 08:44:33 -07:00
fsm-settings-win32.c fsmonitor/win32: mark unused parameter in fsm_os__incompatible() 2023-09-18 15:56:15 -07:00