Limiting syncthing's CPU load

First of all, I’m new to syncthing and so far it is a great tool. Really good job by the programmers. One thing though I noticed, is the high CPU load, that makes my laptop sometimes unusable, when files are scaned or synced. The problem I see is, that syncthing uses all cores to perform tasks as fast as possible. This makes sometimes working with the computer impossible.

For me, syncthing should be a background service, so going unnoticed. For that, it can be work more slowly as possible, as long as it does not disturbe me working on the pc. I don’t mind if the sync takes 1min or 10mins, if I can still use my computer in that time.

So my suggestion is to add an option to limit the CPU load or just to limit syncthing to sequential, using only one core, so it behaves more like a background service.

Once more, I am new, so I have no idea about the code and technical stuff. This is only an idea, that I think, would be worth a discussion.

There’s an environment variable that can be set, GOMAXPROCS (details in syncthing -help). Setting it under Windows is a bit unintuitive and annoying probably, but it is used to limit the number of CPU cores used.

Great, exactly what I need. I only searched the settings, so sorry for that.

I’ve got an alternative solution on the mac using ‘cputhrottle’ available from brew.

Install cputhrottle brew install cputhrottle Create the following script

#!/usr/bin/env bash
SYNC_THING_ID=`ps -A | grep -m1 syncthing | awk '{print $1}'`
sudo cputhrottle $SYNC_THING_ID 10 &

Change the 10 there to suit your needs, it is the CPU % use.

you have to run this everytime you want to throttle syncthing, currently researching a permanent solution.

Where do I find these environment variables on Windows 7? I checked the help but it only states what the variables do and not where to find the variables.

Google how to set environment variables on your OS. You can also adjust syncthings priority in the task manager, by rightclicking on process.

If you’re using SyncTrayzor, that also had a setting to set Syncthing’s CPU priority.

I know this is an old thread…

Just for my understanding, I’m an amateur admin trying to run my own infrastructure whenever I can…

So on macos I would do the following to limit CPU usage to 50% ( on a 4-core system):

Edit this file: ~/Library/Application Support/Syncthing/config.xml

Add this line (because this option was not in there) to the end of the options block: <GOMAXPROCS>2</GOMAXPROCS>

It’s specified via a shell environment, so if you were to launch Syncthing from a command-line on macOS (and Linux):

export GOMAXPROCS=2 ; syncthing

The environment variable can also be set so that it applies when macOS / Linux boots up so that it’s available any time no matter how Syncthing is launched.

Thank you for taking the time.

This opens another rabbit hole of learning for me…

I’m running the application bundle version of syncthing for macos.

How would I do it there then?

Or maybe I should ask this question in the issues in the github for the application bundle?

The Syncthing app bundle for macOS is a nice slim wrapper plus the Syncthing executable (directly from GitHub). Generally speaking, environment variables are visible to all applications.

There are several different ways to set an environment variable, but to avoid conflicts and for flexibility given the goal, setting it via your login profile is a good place.

You didn’t mention which version of macOS, so first find out what your login shell is. To see all current environment variables that have been defined, use the following command:

env

To see just the one that indicates your login shell:

echo $SHELL

If you’re using Z shell (/bin/zsh), update ~/.zprofile. If it’s Bash (/bin/bash), update ~/.bash_profile.

For full effect, log off and log back on.

It’s really a macOS question, so Googling for “macOS shell” would be a better option.