Repository navigation
Description
(Please refer to https://forum.syncthing.net/t/completely-prevent-syncthing-from-traversing-a-directory-subtree/15060 for context.)
problem
Consider the following .stignore:
// .stignore.work -- ignore all except "work" (unique files and work-critical configuration)
!/Documents
!/devel
!/.gitconfig.*
!/.profile.*
!/.kube
!/.config/gcloud
!/.stignore.*
*
When enabling filesystem watching, Syncthing Web UI displays the following error:
Filesystem Watcher Errors
For the following folders an error occurred while starting to watch for changes. It will be retried every minute, so the errors might go away soon. If they persist, try to fix the underlying issue and ask for help if you can't.
error while traversing /home/intelfx/.local/share/containers/storage/btrfs/subvolumes/05fadaaa4dcce2b1a1ca001bd1512826d5df49fd7495cf6a4495b219e27d4294/var/cache/apt/archives/partial: permission denied
Additionally, this causes Syncthing to permanently hog 100% CPU, apparently spent in repeated attempts to set up inotify for ~/.local (a huge directory tree). In this configuration, Syncthing should not attempt to look into ~/.local at all.
(This problem goes away when the !/.config/gcloud include pattern is removed from .stignore.)
feature request
This feature request is about making .stignore parser smart enough to prune ignored subtrees from all further processing even in presence of complex include statements.
Alternatively, there could be an overriding "priority ignore" list that will exclude specific directories from any and all further processing, disregarding all other rules.
what problem your new feature would solve
excessive CPU usage when using complex whitelist-style .stignore configurations in presence of very large and potentially inaccessible (ignored) subtrees
how or why you think it is generally useful (i.e., not just for you)
directories are sometimes ignored for a reason — Syncthing should not even attempt to access them, potentially burning many cycles and energy on constrained devices
what alternatives or workarounds you considered
| workaround | rationale |
|---|---|
removing non-toplevel include patterns from .stignore |
I can live without .config/gcloud, but obviously this kind of solution is not always possible |
configuring the OS to hide problematic directories from Syncthing (e. g. via configuring InaccessiblePaths= in systemd unit or otherwise utilizing mount namespaces) |
this requires root access to the system which is not always present or convenient |
Activity
AudriusButkevicius commentedon May 25, 2020
My gut says there already exists an issue for this. Have you done a search before opening this?
intelfx commentedon May 25, 2020
@AudriusButkevicius Yes, I did a cursory search for "stignore" and "include" in open issues and didn't see anything that would catch my eye. I could be wrong, of course.
The closest I know to my issue is #6072 which deals with a specific side effect rather than the general idea of better ignores handling.
AudriusButkevicius commentedon May 25, 2020
To be honest, I think it's the same thing, in terms of what the implementation will have to do, so I feel we should close this.
intelfx commentedon May 25, 2020
@AudriusButkevicius Is it? #6072 can be fixed with masking permission errors from the watcher, which does not solve the underlying issue of spending cycles on an ignored subtree. What if one of the ignored subtrees was a networked FUSE filesystem with complex semantics?
AudriusButkevicius commentedon May 25, 2020
I don't think we really care about fuse filesystems with complex semantics.
We assume a normal filesystem, and at the moment you start introducing something fancy like encfs or whatever, it becomes your problem, not ours.
[-]RFE: do not traverse ignored directories in presence of non-toplevel .stignore includes[/-][+]Smarter subtree pruning when walking with ignore exclusions[/+]calmh commentedon Aug 31, 2020
I think this is a valid issue, even if just as an optimization. Currently our optimization is quite simple. If we had a function to answer the question "can anything underneath this subtree ever match any of the exclude patterns" then we could avoid walking & watching those subtrees.
AudriusButkevicius commentedon Aug 31, 2020
But how is this different from #6072 so that we let it live?
calmh commentedon Aug 31, 2020
It isn't, but that one looks like it's all about handling permissions issues, while this one is clearer. This one lives, that one dies, I clean up this one.
nalt commentedon Sep 1, 2020
100% CPU also means increased power consumption and constant disk activity. With this behaviour you cannot really run syncthing as a background daemon. So this issue should be more than an enhancement.
It seems that the external watcher didn't have this problem, after issue 161 has been fixed. Could any insight be taken from there?
calmh commentedon Sep 1, 2020
I think we fixed too-fast watcher retries a while back?