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
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
I'm doing "remote development", where I edit sources locally, and they're compiled/executed on a remote, faster machine.
I'm currently using lsyncd. Syncthing can almost cover this use case; unfortunately, it introduces unnecessary latency due to fsWatcherDelayS, which can't be set lower than one second. Depending on circumstances, this reduces or even cancels out the advantage of compiling/executing on the faster machine.
Ideally, it would be possible to specify a fractional fsWatcherDelayS, or an integer fsWatcherDelayMs.
Reacted by Gahl Saraf, Jonathan, Tomasz Wilczyński, Damian Krystkiewicz, Devin, Alexander Lyzhov and Tomas Sandven
I don't see syncthing as a zero latency mirroring application.
There is a cost associated with starting a scan, so I am not sure that doing on every file change is feasible, so I think you are simply using the wrong tool.
Well, I mean, that’s a trade off that might be legitimate, so I don’t think we need to enforce it. There will presumably be some natural batching anyway for changes happening while we’re scanning the previous changes.
I think I'm missing some important pieces of the puzzle. I thought that the mode of operation is:
receive change notification
receive change notification
receive change notification
[...]
when no change received for fsWatcherDelayS seconds:
a. scan files for which a notification was received
b. synchronize
If that's correct (which might totally not be, I haven't dug deep into the sources), then the cost of 4a is proportional to the number of files, and unless one types real fast, I don't foresee many saves in less than one second. :) Also, fsWatcherDelayS is per-folder, so it would seem safe to give the option.
Again, writing all this without deep knowledge of the internals.
There is a some cost for setting up step 4, getting database snapshots, locks etc. With "no delay", that cost would have to be paid on every file change., potentially introducing enough latency that dropping the delay below 1 second wouldn't make much difference.
I did a quick test by applying a one-line hack in aggregator.go to switch from seconds to milliseconds, and left fsWatcherDelayS at the default value of 10. I must say it works even better than I hoped. This is the effect when sharing the syncthing source repo with a remote machine (on the left) which is ~30ms ping time away:
As I said, just a hack, no pretense of contributable code:
Changing that variable to be milliseconds is not "free", as it requires a config migration, and the old field will have to be present in the config structure potentially forever.
Allowing value of zero is not sensible, as if you did something like a git checkout k8s project, it would end up consuming unreasonable amount of resources.
Personally, I'd say that perhaps maintaining a fork for your use case is the right way forward here, but that is my opinion, and other maintainers might have a different view.
Allowing value of zero is not sensible, as if you did something like a git checkout k8s project, it would end up consuming unreasonable amount of resources.
and then compiled a custom build. I created a new folder, set the watcher delay to 0, and then ran a piece of software inside it that creates and modifies thousands of files very quickly. As expected, Syncthing was picking up the changes almost immediately as they were taking place. I didn't experience any extraordinary resource usage though (on Ryzen 4350G with a mid-range SSD). The Web GUI was indeed going a little crazy, changing the folder status back and forth almost constantly.
Nevertheless, would it bring any harm if a value of 0 was simply allowed for special cases like the one described here? Syncthing already allows much more dangerous custom configuration (e.g. disable fsync, etc.). There is no danger in this one except for potentially higher resource usage, right?
Currently, with the shortest possible watch delay of 1, the deletion delay is 6, right? Will deletion delay also become 0 when watch delay is set to 0?
Reacted by Gahl Saraf, Damian Krystkiewicz, Tomas Sandven and Oliver Freyermuth
Logically it should. I think this is fine. You'll miss out on rename optimizations and whatnot, but if you're tuning this for Ultimate Speed(tm) then that's what you're tuning for.
Crap. I'm using syncthing for the same reason as the issue author. I've spent several hours setting up syncthing on my local PC and on my remote server through Docker, and only now do I find out it's too slow for my use case, it takes 8-9 seconds from I hit save until the remote file is updated.
Was this issue ever resolved? Can I tune syncthing to be faster? (Preferably sub-second?)
EDIT: Ah, I'm a sloppy reader, I just now noticed the fsWatcherDelayS setting. I reduced it to 1 and it drastically improved things. There's still a 1-2 second delay, though. Is there currently anything that can be done to reduce it?
Unfortunately, no. In the linked PR, I got stuck on code related to usage reporting and wasn't able to finish it. Someone with better Go skills should probably be able to accomplish this quite easily.
At the moment, the value of 1 will allow Syncthing to sync new files and modifications in 1 second, and deletions in 6 seconds.
It works just fine with sub-second delays, file synchronization is near immediate and I haven't seen side effects (e.g. when synchronizing large amount of files).
The only thing preventing official Syncthing from doing the same is that the configuration delay parameter is implemented as an integer. In the fork, I hacked around thtat by leaving the parameter as integer but making Syncthing interpret it as milliseconds. I've tried to make a case in this issue for a proper fix, changing the parameter type to a float (see discussion above) but without luck.
There. You'll have to configure it manually in the config file though, because the advanced config editor doesn't accept floats and I couldn't figure out why in a reasonable amount of time (it's an <input type=number> 🤷 )
There. You'll have to configure it manually in the config file though, because the advanced config editor doesn't accept floats and I couldn't figure out why in a reasonable amount of time (it's an <input type=number> 🤷 )
I think this may be browser-dependent? I've just tried in Chromium, and I can input numbers like 0.1 or 0.01 with no problems (and they do save properly into config).
By the way, thank you very much for completing the PR 🙂.
Woah, this was quite the surprise. Thank you both. :)
About the <input>: I couldn't immediately find it (happy to have a look — can you point me to it?) but usually fiddling with the min and step parameters tames float-related matters.
The inputTypeFor(...) method returns number for all numeric inputs. I suspect the rest of the problem is somewhere in angular, which I'm not interested in trying to debug. Also, making an exception for this field specifically is tricky given how all this is auto generated from the actual config json.
Reacted by Massimiliano Mirra and Oliver Freyermuth
Please reveal shortDelayMultiplicator in Advanced settings.
Also +1 to subsecond delays.
Having forceful scans (not fsWatcher) writes 57 bytes each scan (every second) into "indexed*/*.log", While fsWatcher writes 109 bytes every 36 seconds. Would also be nice to disable these pointless? writes at all.
Not related to issue but having some buffering (1-10s) is hugely beneficial when many small files sent to another device and another device immediately deletes them because each file issues ~4-5 kb writes to "indexed*/*.log".
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Activity
AudriusButkevicius commentedon Jul 31, 2021
I don't see syncthing as a zero latency mirroring application.
There is a cost associated with starting a scan, so I am not sure that doing on every file change is feasible, so I think you are simply using the wrong tool.
calmh commentedon Jul 31, 2021
Well, I mean, that’s a trade off that might be legitimate, so I don’t think we need to enforce it. There will presumably be some natural batching anyway for changes happening while we’re scanning the previous changes.
AudriusButkevicius commentedon Jul 31, 2021
I fear that the behaviour will not be what the user expects, given scanning and syncing is exclusive.
bard commentedon Jul 31, 2021
I think I'm missing some important pieces of the puzzle. I thought that the mode of operation is:
[...]
fsWatcherDelaySseconds:a. scan files for which a notification was received
b. synchronize
If that's correct (which might totally not be, I haven't dug deep into the sources), then the cost of 4a is proportional to the number of files, and unless one types real fast, I don't foresee many saves in less than one second. :) Also,
fsWatcherDelaySis per-folder, so it would seem safe to give the option.Again, writing all this without deep knowledge of the internals.
FYI, there's at least one project that is relying on Syncthing for remote development: https://github.com/okteto/okteto. (I did try it but ran into the latency issue.)
AudriusButkevicius commentedon Jul 31, 2021
There is a some cost for setting up step 4, getting database snapshots, locks etc. With "no delay", that cost would have to be paid on every file change., potentially introducing enough latency that dropping the delay below 1 second wouldn't make much difference.
bard commentedon Jul 31, 2021
I did a quick test by applying a one-line hack in
aggregator.goto switch from seconds to milliseconds, and leftfsWatcherDelaySat the default value of 10. I must say it works even better than I hoped. This is the effect when sharing the syncthing source repo with a remote machine (on the left) which is ~30ms ping time away:As I said, just a hack, no pretense of contributable code:
} func (a *aggregator) updateConfig(folderCfg config.FolderConfiguration) { - a.notifyDelay = time.Duration(folderCfg.FSWatcherDelayS) * time.Second + a.notifyDelay = time.Duration(folderCfg.FSWatcherDelayS) * time.Millisecond a.notifyTimeout = notifyTimeout(folderCfg.FSWatcherDelayS) a.folderCfg = folderCfg }AudriusButkevicius commentedon Jul 31, 2021
Changing that variable to be milliseconds is not "free", as it requires a config migration, and the old field will have to be present in the config structure potentially forever.
Allowing value of zero is not sensible, as if you did something like a git checkout k8s project, it would end up consuming unreasonable amount of resources.
Personally, I'd say that perhaps maintaining a fork for your use case is the right way forward here, but that is my opinion, and other maintainers might have a different view.
calmh commentedon Jul 31, 2021
It might be mostly free to change the type to float and keep the seconds unit.
tomasz1986 commentedon Aug 2, 2021
I changed
syncthing/lib/config/folderconfiguration.go
Lines 191 to 194 in 0126188
to
and then compiled a custom build. I created a new folder, set the watcher delay to
0, and then ran a piece of software inside it that creates and modifies thousands of files very quickly. As expected, Syncthing was picking up the changes almost immediately as they were taking place. I didn't experience any extraordinary resource usage though (on Ryzen 4350G with a mid-range SSD). The Web GUI was indeed going a little crazy, changing the folder status back and forth almost constantly.Nevertheless, would it bring any harm if a value of
0was simply allowed for special cases like the one described here? Syncthing already allows much more dangerous custom configuration (e.g. disable fsync, etc.). There is no danger in this one except for potentially higher resource usage, right?Edit:
There is also this part of the code:
syncthing/lib/watchaggregator/aggregator.go
Lines 456 to 473 in 37d0ba1
Currently, with the shortest possible watch delay of
1, the deletion delay is6, right? Will deletion delay also become0when watch delay is set to0?calmh commentedon Aug 2, 2021
Logically it should. I think this is fine. You'll miss out on rename optimizations and whatnot, but if you're tuning this for Ultimate Speed(tm) then that's what you're tuning for.
lib/config: Allow to disable file watcher delay (ref syncthing#7859)
lib/config: Allow sub-second watcher delay (fixes syncthing#7859)
Hubro commentedon Nov 20, 2022
Crap. I'm using syncthing for the same reason as the issue author. I've spent several hours setting up syncthing on my local PC and on my remote server through Docker, and only now do I find out it's too slow for my use case, it takes 8-9 seconds from I hit save until the remote file is updated.
Was this issue ever resolved? Can I tune syncthing to be faster? (Preferably sub-second?)
EDIT: Ah, I'm a sloppy reader, I just now noticed the
fsWatcherDelaySsetting. I reduced it to 1 and it drastically improved things. There's still a 1-2 second delay, though. Is there currently anything that can be done to reduce it?tomasz1986 commentedon Nov 20, 2022
Unfortunately, no. In the linked PR, I got stuck on code related to usage reporting and wasn't able to finish it. Someone with better Go skills should probably be able to accomplish this quite easily.
At the moment, the value of
1will allow Syncthing to sync new files and modifications in 1 second, and deletions in 6 seconds.bard commentedon Mar 17, 2023
@Hubro sorry I didn't see this sooner. I've been using a minimally patched version without problems for more than a year at this point: https://github.com/bard/syncthing/tree/instant-sync (it's not in sync with upstream though).
It works just fine with sub-second delays, file synchronization is near immediate and I haven't seen side effects (e.g. when synchronizing large amount of files).
The only thing preventing official Syncthing from doing the same is that the configuration delay parameter is implemented as an integer. In the fork, I hacked around thtat by leaving the parameter as integer but making Syncthing interpret it as milliseconds. I've tried to make a case in this issue for a proper fix, changing the parameter type to a float (see discussion above) but without luck.
calmh commentedon Mar 18, 2023
There. You'll have to configure it manually in the config file though, because the advanced config editor doesn't accept floats and I couldn't figure out why in a reasonable amount of time (it's an
<input type=number>🤷 )tomasz1986 commentedon Mar 18, 2023
I think this may be browser-dependent? I've just tried in Chromium, and I can input numbers like
0.1or0.01with no problems (and they do save properly into config).By the way, thank you very much for completing the PR 🙂.
bard commentedon Mar 18, 2023
Woah, this was quite the surprise. Thank you both. :)
About the
<input>: I couldn't immediately find it (happy to have a look — can you point me to it?) but usually fiddling with theminandstepparameters tames float-related matters.calmh commentedon Mar 18, 2023
It's in the auto generated advanced editor:
syncthing/gui/default/syncthing/settings/advancedSettingsModalView.html
Line 90 in 2bcaa17
The
inputTypeFor(...)method returnsnumberfor all numeric inputs. I suspect the rest of the problem is somewhere in angular, which I'm not interested in trying to debug. Also, making an exception for this field specifically is tricky given how all this is auto generated from the actual config json.Merge branch 'main' into windowsfixtests
Devocub commentedon Jun 13, 2023
Please reveal shortDelayMultiplicator in Advanced settings.
Also +1 to subsecond delays.
Having forceful scans (not fsWatcher) writes 57 bytes each scan (every second) into "indexed*/*.log", While fsWatcher writes 109 bytes every 36 seconds. Would also be nice to disable these pointless? writes at all.
Not related to issue but having some buffering (1-10s) is hugely beneficial when many small files sent to another device and another device immediately deletes them because each file issues ~4-5 kb writes to "indexed*/*.log".
lib/config: Allow sub-second watcher delay (fixes syncthing#7859) (sy…