Continuous high CPU Usage

I’m using Syncthing to sync my home directory between 2 Linux servers, both running Ubuntu. I use a remote desktop (KDE over VNC) sometimes on one or the other of these servers (never both at the same time).

Whenever I’m using the remote desktop, using normal desktop programs like Firefox, Thunderbird, KDE Dolphin etc, CPU usage is extremely high. It’s at about 100% of both CPU’s on the remote Linux server (a VPS), and at least 50% of each of the 4 CPUs on the other machine (refer screenshot). The high CPU usage lasts for several minutes after I close all programs on the remote desktop.

I’ve changed fsWatcherDelayS from the default of 10 secs to 180 secs, but this hasn’t helped. I ran syncthing with STTRACE=scanner syncthing. Looking in the output of this I only saw a small number of file paths it had to walk, for example over a ~3 minute period it found less than 30 file paths, most of which looked like Firefox files (Firefox was running at the time).

What can I do to stop excessive CPU usage?

Check the recent change log, I suspect you are syncing some database which causes other devices to bombard you with requests for the constantly changing files.

This is with just Firefox and Pidgin running:

    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/datareporting/aborted-session-ping |2018-06-30 06:32:52|
    |---|---|---|---|---|---|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/sessionstore-backups/recovery.baklz4 |2018-06-30 06:32:26|
    |hostname.domain |modified |file |home-tim |.purple/blist.xml |2018-06-30 06:32:26|
    |hostname.domain |modified |file |home-tim |.purple/logs/facebook/Me83/1372172950/2018-06-30.063008+0200CEST.html |2018-06-30 06:32:04|
    |hostname.domain |modified |file |home-tim |.purple/logs/facebook/Me83/1372172950/2018-06-30.063008+0200CEST.html |2018-06-30 06:30:58|
    |hostname.domain |modified |file |home-tim |.purple/logs/facebook/Me83/1372172950/2018-06-30.063008+0200CEST.html |2018-06-30 06:30:46|
    |hostname.domain |modified |file |home-tim |.purple/prefs.xml |2018-06-30 06:30:33|
    |hostname.domain |added |file |home-tim |.purple/logs/facebook/Me83/1372172950/2018-06-30.063008+0200CEST.html |2018-06-30 06:30:21|
    |hostname.domain |modified |file |home-tim |.purple/blist.xml |2018-06-30 06:30:21|
    |hostname.domain |modified |file |home-tim |.viminfo |2018-06-30 06:29:52|
    |hostname.domain |added |file |home-tim |TIM'S FOLDER/TIM'S DOCUMENTS/Computer Stuff/HOWTOs/Linux/system/Linux General Monitoring.txt |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/sessionstore-backups/recovery.jsonlz4 |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/sessionstore-backups/recovery.baklz4 |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/places.sqlite |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/datareporting/aborted-session-ping |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/SiteSecurityServiceState.txt |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/weave/changes/clients.json |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/weave/failed/clients.json |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/weave/failed/bookmarks.json |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.mozilla/firefox/bcw9budh.Tim Profile May 2017 Onwards/prefs.js |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.purple/blist.xml |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.purple/accels |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.purple/telegram-purple/+61401514597/auth |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.purple/logs/facebook/Me83/1372172950/2018-06-30.062402+0200CEST.html |2018-06-30 06:29:52|
    |hostname.domain |modified |file |home-tim |.purple/accounts.xml |2018-06-30 06:29:52|


The Dstat output (see screenshot as well):
    $ cat Downloads/dstat 
    30-06 06:28:37|  2   1  97   0   0   0|   0    16k|2430B  869B|   0     0 | 170   302 |firefox      0.3
    30-06 06:28:47|  1   1  97   1   0   0|   0    30k|1382B  741B|   0     0 | 152   222 |firefox      0.5
    30-06 06:28:57|  2   1  97   0   0   0|   0    10k|2648B  563B|   0     0 | 184   431 |firefox      0.9
    ----system---- ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- -most-expensive-
         time     |usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw |  cpu process   
    30-06 06:29:07| 10   4  85   1   0   0|  21k   19k|  10k   57k|   0     0 | 662  1953 |pidgin       2.6
    30-06 06:29:17| 10   4  85   0   0   0|   0    22k|  11k   51k|   0     0 | 838  2067 |firefox      4.5
    30-06 06:29:27| 50  12  38   0   0   0| 410B  153k|  11k   29k|   0     0 |1164  2847 |syncthing     43
    30-06 06:29:37| 90   9   2   0   0   0|   0    54k|3668B 1965B|   0     0 | 928  1011 |syncthing     94
    30-06 06:29:47| 86  12   2   0   0   0|   0    27k|2263B 2534B|   0     0 | 918  1159 |syncthing     95
    30-06 06:29:57| 62  11  26   0   0   0|   0    59k|4535B  126k|   0     0 | 803  1141 |syncthing     69
    30-06 06:30:07| 45   9  44   1   0   1|  19k   10k|9404B   81k|   0     0 | 656   643 |syncthing     52
    30-06 06:30:17| 59   7  20  14   0   0|1805k   62k|2307B 5563B|   0     0 | 741  1202 |syncthing     56
    30-06 06:30:27| 78   4  18   0   0   0|   0    38k|3244B 4449B|   0     0 |1339  2315 |syncthing     77
    30-06 06:30:37| 94   4   2   0   0   0| 819B   21k|1847B 3307B|   0     0 |1344  2150 |syncthing     93
    30-06 06:30:47| 93   4   3   0   0   0|   0    31k|2434B 2834B|   0     0 |1522  2689 |syncthing     93
    30-06 06:30:57| 93   4   3   0   0   0|4506B 9011B|2413B 4030B|   0     0 |1574  2835 |syncthing     93
    30-06 06:31:07| 92   5   3   0   0   0|   0    64k|2715B 4344B|   0     0 |1214  1890 |syncthing     91
    30-06 06:31:17| 77   4  19   0   0   0|   0    14k|2058B 2255B|   0     0 |1065  1689 |syncthing     78
    30-06 06:31:27|  3   1  96   0   0   0|   0    14k|2100B 2011B|   0     0 | 219   487 |firefox      0.8
    30-06 06:31:37|  2   1  97   0   0   0|   0    17k|2257B  669B|   0     0 | 159   290 |firefox      0.2
    30-06 06:31:47|  1   1  97   0   0   0|   0  6554B|1613B 1150B|   0     0 | 156   305 |firefox      0.5
    30-06 06:31:57|  2   1  97   0   0   0|   0    24k|2440B 1467B|   0     0 | 179   340 |firefox      0.4
    30-06 06:32:07| 31   5  63   0   0   0| 410B   46k|9982B   33k|   0     0 |1044  3003 |syncthing     23

In the end I disabled the inotify (watching for changes) and just set it to scan every 3 mins. This seems to reduce CPU usage so it takes 100% of one CPU (instead of both) for only about 30 secs every 3 mins. Not ideal, but it’s a balance between syncing changes often and actually being able to use the computer

You must be syncing something like a database that always changes that causes this.

Nothing like that came up in the ‘recent changes’, apart from the usual Firefox files. But even if I didn’t run Firefox or Thunderbird (which both use sqlite DBs) and just browsing around with Dolphin the high CPU usage seemed to come up.

Do I need to specifically exclude the Syncthing index (.config/syncthing/index-v0.14.0.db/) from the sync? Would it make sense even to delete these indexes and let syncthing create them again, assuming they’ve somehow grown too big or got corrupt or something?

You should not sync Syncthing index/config, I guess this is what is constantly triggering the file watcher. I wouldn’t sync FF and TB folders either. Better to use addons or IMAP server for that.

This will be the culprit. With Io fswatcher on the ST database changing will rigger a rescan of the ST database which then states the new index and causes a rescan.

Even without fswatcher on you shouldn’t share the active ST folder.

No luck, I just checked my stignore file and /.config/syncthing was already in there.

Is there a way to reset that index/databases? On the assumption that somehow it’s become too big or corrupt (I’ve been running home-folder syncthing between these 2 machines since March 2017).

There is -reset-database command line switch but you should make sure devices are in sync. I am also very skeptical that that this will fix it. I am pretty sure you have something that changes constantly.

I suspect Audrius is correct. Perhaps you could try syncing the /home/Documents folder and it’s siblings individually and then pausing some of them to narrow down where your constantly changing files might be?

Thanks, I’ll be a bit busy over the next few days but when I get time I’ll try those suggestions

I tried -reset-database and it might have helped a bit, but hasn’t completely solved the problem.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.