You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Watching for changes using too many system resources on BSDs (kqueue) #7855
bugA problem with current functionality, as opposed to missing functionality (enhancement)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
We should somehow prevent this. Either disabling kqueue alltogether or adding a limit for items in a folder (disable kqueue once reached). The latter will be somewhat annoying, as I guess users will want to adjust/override that, and we'd need to enable watching only after the initial scan (so we know how many items there are). However just disabling it will probably make a lot of people mad.
Thanks for adding this issue @imsodin. As you noted via the above forum post link, this issue bit me hard this week, so I would have benefited from some kind of mitigation.
Changing the defaults when the host is BSD would have been helpful, but honestly would not have helped me that much, because I probably would have simply turned it on when I set everything up.
Honestly, as a sysadmin, I would cast my vote for a UI warning along with some clear documentation around the risks and tradeoffs of enabling the feature. I think that would have saved me a couple days of hair-pulling.
To further clarify, I don't think the biggest issue is the performance impact itself. I think the biggest issue was the mystery of trying to figure out what was causing the performance impact. So a clear UI warning would have been incredibly helpful.
Thanks again for working on Syncthing. It's pretty incredible!
I agree, it took me several weeks of screwing around to finally figure out why anytime Syncthing was enabled my system would CRAWL and be literally unusable (which was tough to troubleshoot because the shell and webgui would actually time out before getting a response.) I was trying to install custom Syncthing jails with resource limits and all kinds of circular goose chasing, only to find out it was just an otherwise innocent looking setting...
So perhaps a one time notification similar to the "you should set up authentication" one, like "my dude, you're on a system with kqueue, use filesystem notifications with care and be aware that enabling it for large folders will use lots of system resources", perhaps with a link to some suitable doc article / faq...
Exactly. Just something to make the average user aware of the performance impact. For me, the filesystem watcher works flawlessly on my Windows and my prior Linux setup, but the FreeBSD version (that i only started using/learning a month ago) basically left me completely unaware.
Otherwise, its a pretty nice bit of code you've got here.
Right. That is a fair point you have there.. Perhaps rookie, inexperienced or just plain dumbass (me) users might have been more precise - hard to say. Bahaha
i think, regardless of the user-model, (this) software should give relevant information to the user in order to not waste their time. So a notification should be fine. This would be in the bsd-spirit 😄
Just got this warning for a bunch of Syncthing folders that had 0 files since update and restart (used for auto cloning between systems with manual deletion after move to final destination).
Seeing that kqueueItemCountThreshold = 10000 and the condition for warning is summary.Data.(map[string]interface{})["localTotalItems"].(int) > kqueueItemCountThreshold
I am now confused as to what localTotalItems is and where exactly I should avoid enabling FS watching.
Is it Local State (Total) number of files in this instance of Syncthing, 100k in my case, and it is a bad idea to enable FS watching an any of the folders not considering the actual amount of files in them?
I am a bit confused as you are saying first 0 files then 100k? Anyway I can't tell you if it's a problem, but I assume if you don't observe anyproblems with your current set up, semms like it's fine. Generally lets please take further discussion on your specific use-case to https://forum.syncthing.net, we handle support-like discussions there.
Maybe emitting a warning for this is too much and "INFO" would have been the sweet spot. The reason I used a warning is that hardly anyone notices an info level line in the logs. However that might just be a good thing: Dosn't spook anyone, but if issues arise there's a hint in the logs if anyone starts digging.
I have two FreeBSD systems syncing the same sets of files. I had to increase kern.maxfiles sysctl when first setting them up, but they have worked well up until this revision. Global state is 90,262 files, 8,127 directories, ~343 GiB.
I get the warning even for sets with only 10 files in one directory.
Disabling file system watching does not reduce the system load. Even scanning a set with 10 files bumps CPU to 95% for 15-20 seconds. Previously syncthing CPU usage was less than a few percent almost all the time.
One system has UFS, the other has ZFS. UFS has become almost unusable unless I pause all but the smallest sets. ZFS CPU usage has jumped to between 40-50% during rescans, but otherwise the system is still usable.
Reverting to v1.19.2 on the UFS system seems to return the CPU usage to a sane level -- peaks to 95% for a few seconds when unpausing large sets, but dropping below 60-70% for 15-20 seconds while scanning all sets, then dropping to less than 1% overall.
I will leave upgrades disabled and watch this version to confirm, but so far it seems to undo the CPU usage problem.
I am a bit confused as you are saying first 0 files then 100k?
Sorry, for late reply, missed notification. 100k is the total number of files in all of Syncthing's (TrueNAS jail) folders, which includes ZFS mounts from 5 different pools.
Not that I was seeking support, but rather was trying to clarify how kqueue works in order to understand this limitation, particularly what is the context for this 10k threshold. Is it single Syncthing folder that is being watched, or an underlying filesystem of that mount, or even the filesystem of the whole jail including all mounts.
For the sake of curious minds that would come across this thread as it is the only thing coming up during research of the warning. Anyway, hope we are talking about the same issue and last commit fixes things.
That's weird, now I can't come up with an explanation anymore. Can you run Syncthing with -verbose or enable events debug logging and look for FolderSummaries and post a few of those here please (those are used to trigger this warning).
You did also get a new warning in the logs? Not just that you didn't press ok in the web UI (grasping at straws here).
Yeah, I though that warning could be carried from previous version in case I did not press "OK", but I rechecked that multiple times since then, hit "OK", had restarts, but it persistently pops up again (both GUI and logs) on every restart.
bugA problem with current functionality, as opposed to missing functionality (enhancement)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Activity
alexmarkley commentedon Jul 29, 2021
Thanks for adding this issue @imsodin. As you noted via the above forum post link, this issue bit me hard this week, so I would have benefited from some kind of mitigation.
Changing the defaults when the host is BSD would have been helpful, but honestly would not have helped me that much, because I probably would have simply turned it on when I set everything up.
Honestly, as a sysadmin, I would cast my vote for a UI warning along with some clear documentation around the risks and tradeoffs of enabling the feature. I think that would have saved me a couple days of hair-pulling.
To further clarify, I don't think the biggest issue is the performance impact itself. I think the biggest issue was the mystery of trying to figure out what was causing the performance impact. So a clear UI warning would have been incredibly helpful.
Thanks again for working on Syncthing. It's pretty incredible!
koskee commentedon Nov 23, 2021
I agree, it took me several weeks of screwing around to finally figure out why anytime Syncthing was enabled my system would CRAWL and be literally unusable (which was tough to troubleshoot because the shell and webgui would actually time out before getting a response.) I was trying to install custom Syncthing jails with resource limits and all kinds of circular goose chasing, only to find out it was just an otherwise innocent looking setting...
calmh commentedon Nov 24, 2021
So perhaps a one time notification similar to the "you should set up authentication" one, like "my dude, you're on a system with kqueue, use filesystem notifications with care and be aware that enabling it for large folders will use lots of system resources", perhaps with a link to some suitable doc article / faq...
koskee commentedon Nov 24, 2021
Exactly. Just something to make the average user aware of the performance impact. For me, the filesystem watcher works flawlessly on my Windows and my prior Linux setup, but the FreeBSD version (that i only started using/learning a month ago) basically left me completely unaware.
Otherwise, its a pretty nice bit of code you've got here.
AudriusButkevicius commentedon Nov 24, 2021
"Average user" and "BSD" in the same paragraph, wat?
koskee commentedon Nov 24, 2021
Right. That is a fair point you have there.. Perhaps rookie, inexperienced or just plain dumbass (me) users might have been more precise - hard to say. Bahaha
bitclick commentedon Nov 26, 2021
i think, regardless of the user-model, (this) software should give relevant information to the user in order to not waste their time. So a notification should be fine. This would be in the bsd-spirit 😄
pushytoxin commentedon Dec 8, 2021
Is this a scalability issue? Could I fix the hang by adding another 128GB RAM to the box running Syncthing?
AudriusButkevicius commentedon Dec 8, 2021
Its probably cheaper to move to linux, if you can.
pushytoxin commentedon Dec 9, 2021
I already tried and it didn't help
AudriusButkevicius commentedon Dec 9, 2021
Tried what and what didn't help?
pushytoxin commentedon Dec 10, 2021
256GB RAM in the box, the issue described above still happens (~11M files)
AudriusButkevicius commentedon Dec 10, 2021
Yes, on BSD watching large folders does not work, this is what issue talks about.
17 remaining items
pae-id commentedon May 27, 2022
Just got this warning for a bunch of Syncthing folders that had 0 files since update and restart (used for auto cloning between systems with manual deletion after move to final destination).
Seeing that
kqueueItemCountThreshold = 10000and the condition for warning issummary.Data.(map[string]interface{})["localTotalItems"].(int) > kqueueItemCountThresholdI am now confused as to what
localTotalItemsis and where exactly I should avoid enabling FS watching.Is it
Local State (Total)number of files in this instance of Syncthing, 100k in my case, and it is a bad idea to enable FS watching an any of the folders not considering the actual amount of files in them?imsodin commentedon May 27, 2022
I am a bit confused as you are saying first 0 files then 100k? Anyway I can't tell you if it's a problem, but I assume if you don't observe anyproblems with your current set up, semms like it's fine. Generally lets please take further discussion on your specific use-case to https://forum.syncthing.net, we handle support-like discussions there.
Maybe emitting a warning for this is too much and "INFO" would have been the sweet spot. The reason I used a warning is that hardly anyone notices an info level line in the logs. However that might just be a good thing: Dosn't spook anyone, but if issues arise there's a hint in the logs if anyone starts digging.
ajshea commentedon May 28, 2022
Something broke with this revision.
I have two FreeBSD systems syncing the same sets of files. I had to increase kern.maxfiles sysctl when first setting them up, but they have worked well up until this revision. Global state is 90,262 files, 8,127 directories, ~343 GiB.
Reverting to v1.19.2 on the UFS system seems to return the CPU usage to a sane level -- peaks to 95% for a few seconds when unpausing large sets, but dropping below 60-70% for 15-20 seconds while scanning all sets, then dropping to less than 1% overall.
I will leave upgrades disabled and watch this version to confirm, but so far it seems to undo the CPU usage problem.
lib/model: Don't include deleted items in kqueue warning threshold (ref
imsodin commentedon May 28, 2022
The cpu usage problem is definitely not related, all the change did is print a warning - no behaviour change otherwise. Please post on the forum to get help with diagnosing your problem: https://forum.syncthing.net
lib/model: Don't include deleted items in kqueue warning threshold (ref
ajshea commentedon May 28, 2022
Thanks for the clarification.
Something in 1.20 and following definitely changed the CPU usage. I'll post on the forum to see if we can narrow down what changed.
pae-id commentedon May 28, 2022
Sorry, for late reply, missed notification. 100k is the total number of files in all of Syncthing's (TrueNAS jail) folders, which includes ZFS mounts from 5 different pools.
Not that I was seeking support, but rather was trying to clarify how
kqueueworks in order to understand this limitation, particularly what is the context for this 10k threshold. Is it single Syncthing folder that is being watched, or an underlying filesystem of that mount, or even the filesystem of the whole jail including all mounts.For the sake of curious minds that would come across this thread as it is the only thing coming up during research of the warning. Anyway, hope we are talking about the same issue and last commit fixes things.
pae-id commentedon Jun 12, 2022
It still warns about folders with 0 files after a restart on v1.20.2
imsodin commentedon Jun 18, 2022
That's weird, now I can't come up with an explanation anymore. Can you run Syncthing with
-verboseor enableeventsdebug logging and look forFolderSummariesand post a few of those here please (those are used to trigger this warning).pae-id commentedon Jun 20, 2022
Here you go:
Folder "p2p-plex-node1-SYNC"
Folder "p2p-plex-node4-CLONE"
imsodin commentedon Jun 21, 2022
The condition is:
So clearly not fulfilled for the summaries you showed above.
You did also get a new warning in the logs? Not just that you didn't press ok in the web UI (grasping at straws here).
pae-id commentedon Jun 21, 2022
Yeah, I though that warning could be carried from previous version in case I did not press "OK", but I rechecked that multiple times since then, hit "OK", had restarts, but it persistently pops up again (both GUI and logs) on every restart.