Use File System Events To Monitor Workspace #1365
Merged
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.
Description
Removes the existing file system watching code and replaces it with MacOS's File System Events API. This API isn't bound by process file descriptor limits and is built for recursive directory monitoring. In place of file descriptors it uses kernel updates to notify our process that events have occurred.
Changes in detail:
watcherCode
fromCEWorkspaceFile
CEWorkspaceFileManager
.CEWorkspaceFileManager
that allows more than one subscriber to listen for updates to the file tree.DirectoryEventStream
class.0.05s
event debounce and queue events to be received on thedefault
qos dispatch queue.0.05s
was chosen after testing with larger and smaller sizes to find a time that feels snappy while reducing extra events.FSEvents
enum for more info on valid events. The stream will send events on a background thread, so any UI related code will have to be dispatched by the receiver.This has implications for @Wouter01's branch getting rid of
CEWorkspaceFile
. Thankfully, most of the changes here won't effect that PR besides removing some of the work halfway done there. As discussed on Discord, we'll merge this monitoring system in favor of the NSDocument subclassing Wouter was doing and perform any updates needed to use the newResource
protocol on that branch.Related Issues
New File
#1146Checklist
Screenshots
Moving files is snappy and updates consistently (even moving a large project's
node_modules
folder had little to no noticeable effect on this):Screen.Recording.2023-06-29.at.11.30.19.PM.mov
Files created/modified/deleted in the built-in terminal or by other applications update quickly and consistently:
Screen.Recording.2023-06-30.at.9.27.50.PM.mov