Skip to content

Commit 22d450b

Browse files
committed
perf(windows): consolidate watch paths via ConsolidatingPathTrie
Close #62. Mirror the fsevents PR #60 pattern: when 10+ sibling paths are registered under the same parent, collapse them into a single watch on the parent instead of opening one `ReadDirectoryChangesW` handle per child. Implementation: * Replace the `WatchMode` value of `self.watches` with a new `UserWatch` struct that carries the user's intent plus the resolved OS-level primary dir (and optional tracked-parent for `TargetMode::TrackPath`). * Add `rebuild_watch_handles`: build a `ConsolidatingPathTrie` over the primary dirs from every user watch, compute the recursive flag per consolidated target by checking for strict descendants in the user watches, layer in tracked-parent watches that aren't already covered, and diff against the open `watch_handles` to converge the OS state. * `add_watch` / `remove_watch` / `apply_staged` now update `self.watches` first and then call `rebuild_watch_handles` instead of poking `add_watch_raw` directly. * The event filter at `handle_event` was a direct hash lookup on the OS dir name; consolidation can leave the OS dir different from any user request, so it now walks ancestors via `is_event_covered`. * `pre_open_tracked_parent` works around a Windows quirk where calling `path.metadata()` on a directory *before* its parent dir has a `ReadDirectoryChangesW` handle silently drops the parent's later `FILE_ACTION_MODIFIED` event for that directory. The pre-call opens the tracked parent before any metadata is read, matching the order the previous per-call code used. Adds five new tests covering: 10-sibling consolidation, event delivery through a consolidated parent, mixed recursive/non-recursive collapse, de-consolidation when the count drops back below the threshold, and the batched `paths_mut().commit()` path.
1 parent aba6e5c commit 22d450b

1 file changed

Lines changed: 475 additions & 120 deletions

File tree

0 commit comments

Comments
 (0)