git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fsmonitor: flush pending FSEvents before cookie wait

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 24, 2026, 20:38 UTC
Message-ID
<xmqqh5lo5dib.fsf@gitster.g>
In-Reply-To
<CAOTNsDy4pKbPHdK1T688Ax6Mgz15K-qfZR-8fAvTk48z3E43Rg@mail.gmail.com>
Koji Nakamaru <koji.nakamaru@gree.net> writes:
Show 31 quoted lines
> On Wed, Jul 22, 2026 at 6:05 AM Tamir Duberstein <tamird@gmail.com> wrote:
>>
>> 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>
>> ---
>>...
> This patch is carefully designed to minimize any risks. To drain events,
> we could also call FSEventStreamFlushSync before acquiring main_lock in
> do_handle_client(), but this patch should be sufficient if it mitigates
> the issue. The commit message would be much more convincing if you also
> included benchmark results showing how many timeouts were reduced.
Thanks for a review.
Previous: Koji NakamaruNext: Junio C Hamano
Message 3 of 11 in “fsmonitor: flush pending FSEvents before cookie wait”
  1. fsmonitor: flush pending FSEvents before cookie waitTamir Duberstein, Jul 21, 2026
  2. Koji NakamaruJul 24, 2026
  3. Junio C HamanoJul 24, 2026
  4. Junio C HamanoAug 4, 2026
  5. Patrick SteinhardtAug 5, 2026
  6. Tamir DubersteinAug 11, 2026
  7. Patrick SteinhardtAug 11, 2026
  8. Tamir DubersteinAug 11, 2026
  9. Tamir DubersteinAug 13, 2026
  10. Patrick SteinhardtAug 13, 2026
  11. Junio C HamanoAug 11, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.