-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More efficient update checking #5
Comments
|
Oh wow the |
The default inotify limit (amount of watched directories I think) on linux seems to be 8192. This limit is shared among all program (including your editor). You can increase it by writing to An alternative would be to implement a language server using the lsp protocol that only captures which files are changed according to the editor. This would also allow saving each individual keystroke even when the user doesn't explicitly save. In addition the editor extension could then be responsible for ensuring the daemon is running. |
Remarkably overkill solution, but for jauntywunderkind/git-auto-commit, I use facebook/watchman. It's extremely well tuned, and let's me add filters. You can either just exec watchman command line (which runs either runs standalone or via by spawning a server- ideal if there's a lot of different watchers!), or you can talk to a server via it's socket interface (socket with json or bser encoding). There's also watchman_client to facilitate using that socket interface. |
I'd rather not add external dependencies, if possible. I don't mind crates. Another idea — the "tens of thousands" is naive. You could probably narrow it down to ~100 files with 95% confidence. Some ideas for heuristics:
|
Another heuristic would be to inotify-watch files that are currently open (as determined through |
@neinseg I like that, but how long do files stay open? Does Vim or VSCode actually hold the file open? Seems like "opened files" is too ephemeral to work well, but I don't know. If you could watch all file descriptors under |
I'm using a shell implementation of this feature using fswatch (cross-platform file monitor) and Note: this replaces the need for Fish shell implementationset repos (cat ~/.config/dura/config.json | jq -rc '.repos | keys | join("§")' 2>/dev/null)
set pollingSeconds 10
fswatch -e .git -0 -l $pollingSeconds -r (string split '§' -- $repos) | while read -l -z path
cd $path 2>/dev/null || cd (dirname $path) && cd (git rev-parse --show-toplevel) && dura capture
end Bash/Zsh shell implementationrepos=$(cat ~/.config/dura/config.json | jq -rc $'.repos | keys | map("\'\(.)\'") | join(" ")' 2>/dev/null)
pollingSeconds=10
eval "fswatch -e .git -0 -l $pollingSeconds -r $repos" | while read -r -d '' path
do
cd $path 2>/dev/null || cd $(dirname $path) && cd $(git rev-parse --show-toplevel) && dura capture
done How it works?
|
@alin23 can you send a PR to update the README? this is amazing and i don't want to lose it in the issues |
thinking about this... @alin23 maybe we should start adding script files into the core repo for stuff like this. |
Yes, script files would be better. That way you could have a command like |
I love it! Let's do it |
Linux (and macOS) both support an event based API for file watching - perhaps this'd be more efficient than manually checking for updates?
https://crates.io/crates/inotify
https://crates.io/crates/kqueue
are existing bindings.
The text was updated successfully, but these errors were encountered: