Syncthing slow for a big new volume
Frustrating day today setting up a new Syncthing volume. It’s 72GiB, 73_000 files, 36_000 directories. Big but not ridiculous. I’m not syncing the actual data over the Internet. What’s slow instead is Syncthing’s repeated database scans after updates.
The setup: I have a Syncthing hub called “vault”. I have two spokes, “sfld” and “gvld”. I had the files on sfld and gvld already but not under syncthing. My goal at the end was to have vault have the primary copy and sfld and gvld to have identical syncthing clones.
I started by using rsync to copy the files from sfld to vault. Then created the Syncthing volume on vault, then on sfld, then connected them. When that finished I connected gvld to vault as well. It seemed simple but it triggered syncthing scanning a bunch of times.
- 30m: sfld and vault scan their copies in parallel
- 60m: vault matches its records to sfld
- 45m: gvld scans its own copy
- 30m: gvld and vault exchange indexes
- 120m?: vault adopts gvld’s records. sfld adopts in parallel (hopefully)
All in all I think it’s seven scans for nearly five hours. rsync could have figured out they were the same in under a minute. Maybe I did it wrong? Maybe there was some order to do this or some options I could have set to guarantee less rescanning?
This last 120 minute scan may be worse because vault is both doing work itself and processing updates from sfld. I’ve paused sfld: now vault runs twice as fast but then sfld is no longer getting work done in parallel.
An added problem is I hit a performance problem in Syncthing 2 which Claude helped me figure out. Syncthing is O(n^2) if you add N identical small files. In my case I have 45,000 blank map tiles in one of the directory trees and it takes forever to scan them. That accounts for about 20m of three of the scans. This seems like a fixable problem in Syncthing, I hope to file a proper bug report.
The good thing is once Syncthing is done with this initial import I trust later updates to be pretty quick. Although this volume is going to contain lots of data that may change frequently and more big additions will also be slow. This data is “srcbulk”, where I have my various software projects put the output of their runs. Some of my projects can generate 50GB of data in a couple of days that I use for about a week before I remove again. Not ideal to be syncing those between machines but I need it in both places.