Filesystem Monitoring for Worktree Changes #5982
Draft
+0
−0
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.
This PR is about evaluating how to do portable and performance worktree tracking so that changes to the worktree can remain in sync with what's on Disk.
With such a system, keeping the app in sync with what's in disk will have higher performance than it could have if it would do a whole
git status
each timesomething changes on disk.
Requirements
.git
changesVerdict of Research
Even though one could spend time on making the builtin Git daemon usable so that we can…
…it won't actually do anything that our own file system watcher isn't doing already. Further, it won't give any paths that are inside the
.git
directory.I'd rather spend the time making our own filesystem monitor better (possibly after even by contributing fixes to the upstream project) than dealing with Gits monitoring daemon that we can't control nor patch easily.
Something we can certainly learn from is its event handling, it's well thought out and made for robustness.
Also there is always a variant of this 'subscription' system that needs to work without the monitor for network filesystems, so I don't think using Git fsmonitor saves any time (quite the opposite). Let's trust in Rust.
Tasks
git fsmonitor
cli status -w
to watch in the CLIResearch
git fsmonitor--daemon
Here are the docs.
git status
takes 600ms to ~900ms, without it it takes 2.8s. But it's far from instant.watchman
variant, which is very portable, but also a memory hog. Also it's definitely not installed and an installation is isn't always easy as it contains C extensions.git status
operation, and to speed up untracked files one needs to enable the untracked cache as well, at least for Git to make use of it fully.git status
or whatever client we know.fsmonitor.allowRemote=true
.git/
directory where the daemon is available, and that isn't supported on every filesystem the repository could be stored on. If that's the case, the socket is created in$HOME/git-fsmonitor-*
or else the location offsmonitor.socketDir
is used. Finding the right socket isn't entirely trivial but there are sources for that.fsmonitor_ipc__get_path
refresh_fsmonitor
compat/fsmonitor/
For later