feat(file-watcher): start the watcher without blocking the main thread#437
feat(file-watcher): start the watcher without blocking the main thread#437
Conversation
e84d8f0 to
f23e15c
Compare
f23e15c to
cf21bd1
Compare
|
The thing I noticed last time, and maybe the improved gitignore stuff I added helps, was that starting it in an async thread caused a surge of file change events in the initial check, for whatever reason. I'm happy to build this branch on macOS and check that the FS change events work. |
|
Seems to be fine to me. Was starting this on the main thread the cause of a startup delay? |
|
Here's my gitu.log for this session: gitu.logThere are a couple of interesting things:
Maybe none of these are interesting to #374 but I can't really tell since I don't have a repo/system that has these issues, unfortunately. |
|
Nice! It seem like it is a pretty significant amount in larger repos. I found this in the man-page: The filtering done: |
Do you have any idea of how to approach this? Browsing around the docs for |
I noticed you asked this same question on the other thread, but how does magit (or is it emacs?) manage not to run into the same issue? |
|
Also, in this comment the log shows |
|
True. But perhaps he tested it on a Mac as well. It'd be perfect if the |
|
I'll merge this in and create a new issue:
|
There was a problem hiding this comment.
Pull Request Overview
Refactors the file watcher to run in a separate thread to prevent blocking the main thread during initialization. The watcher is now started asynchronously and uses std::mem::forget to prevent it from being dropped.
- Moved file watching logic into a separate
watchfunction that runs in a spawned thread - Removed the
_watcherfield from theFileWatcherstruct since the watcher now runs independently - Added error logging for file watcher failures in the background thread
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@jonathanj put this back in a thread, I can't see how it wouldn't work on Mac. 🤔
This time around the watcher doesn't move around threads.
previously reverted in: #360
related: #358, #374