Skip to content

macOS file monitor: bursts of dropped-event warnings and repeated full-project rescans #18507

Closed

Description

@kevinushey

On macOS, sessions monitoring a large project (e.g. this repository) sporadically log bursts of:

WARNING File monitor events were dropped; rescanning /path/to/project; LOGGED FROM: ... MacFileMonitor.cpp:402

Each warning corresponds to an FSEvents delivery carrying kFSEventStreamEventFlagUserDropped / kFSEventStreamEventFlagKernelDropped, i.e. fseventsd's per-client queue overflowed before rsession drained it. The monitor recovers with a full recursive rescan of the project root.

Two mechanisms make this bursty and expensive:

  1. The session-side ignore filter (.git/, node_modules/, gitignored dirs, etc.) is applied client-side, after delivery. Every event under the root still transits fseventsd's queue, so heavy churn (builds, git operations, npm ci) can overflow it on volume alone.
  2. The recovery rescan runs inline in the FSEvents callback. On a large tree it blocks the run loop long enough for the queue to overflow again, so the next delivery also carries the dropped flag and triggers another full rescan -- one overload episode amplifies into several back-to-back rescans.

Proposed fixes:

  • Use FSEventStreamSetExclusionPaths to suppress events for always-ignored high-churn directories (.git, .Rproj.user, node_modules, ...) at the fseventsd level, reducing queue pressure at the source.
  • Debounce the dropped-event recovery rescan: rescan at most once per interval, and coalesce drops arriving inside the interval into a single deferred trailing rescan.
  • Raise the FSEvents stream latency (currently 1s) for more temporal coalescing in fseventsd; kFSEventStreamCreateFlagNoDefer keeps isolated changes delivered immediately.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions