Watcher backends: merge 'add' and 'change' events into 'touch' #1417
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Refactor watcher backends so that they're not required to disambiguate "add" file events from "change" file events, instead emitting ambiguous "touch" events.
This distinction isn't typically available from the host OS (
fsevents
,ReadDirectoryChangesW
,inotify
), so for the backends to supply it, they must track all files to know whether they existed prior to the OS event. Watchman does this by design anyway, and typically only once per session, but both ourFSEventsWatcher
andNodeWatcher
currently crawl the whole directory tree and keep an in-memory list of files, and must do so on each Metro start.We don't need this information from the watchers anyway, because we can already infer new vs modified according to whether the file is present in
TreeFS
(ie, from the crawl, or subsequent event). Therefore we don't need to reduce the granularity ofmetro-file-map
's public events, only the internal ones.By simplifying this, we can follow up by taking a huge burden off the watcher backends.
Changelog: Internal
Differential Revision: D67579233