Skip to content

FS notification watch aggregator stuck spinning on timers ("CPU Usage High with no mission") #9927

Closed

Description

@zhengran14

What happened?

I encountered this issue on both v1.20 and v1.27.7. Currently, the situation is that I don't have any tasks (there might have been some in the past, but at least right now there are no tasks), and CPU usage randomly spikes to very high levels. At this point, restarting syncthing resolves the issue, but whether it will reoccur or how long it will take to appear is uncertain.
This is the pprof I captured:
cpu pprof
heap pprof

This is the top output:

      flat  flat%   sum%        cum   cum%
    8130ms 20.71% 20.71%     8130ms 20.71%  math.archExp
    7710ms 19.64% 40.35%     7710ms 19.64%  runtime.memclrNoHeapPointers
    3730ms  9.50% 49.85%     3980ms 10.14%  math.log1p
    1310ms  3.34% 53.18%     3970ms 10.11%  runtime.scanobject
    1240ms  3.16% 56.34%     1240ms  3.16%  math.archLog
    1160ms  2.95% 59.30%    16150ms 41.14%  github.com/greatroar/blobloom.fpRate
     590ms  1.50% 60.80%     2340ms  5.96%  github.com/greatroar/blobloom.logPoisson
     540ms  1.38% 62.18%      810ms  2.06%  runtime.findObject
     530ms  1.35% 63.53%      530ms  1.35%  runtime.(*mspan).base (inline)
     490ms  1.25% 64.77%      490ms  1.25%  runtime.futex

Syncthing version

v1.27.7

Platform & operating system

Linux amd64 Debian

Browser version

Safari, Chrome

Relevant log output

Activity

  1. added
    bug
    needs-triage
    on Jan 17, 2025
  2. calmh commented on Jan 17, 2025

    @calmh
    Member

    Looks like it's running database garbage collection. Some CPU usage is expected for that.

  3. zhengran14 commented on Jan 17, 2025

    @zhengran14
    Author

    Looks like it's running database garbage collection. Some CPU usage is expected for that.

    But what's strange is that once it reaches this state, the CPU usage remains high and doesn't decrease, even after days.

  4. calmh commented on Jan 17, 2025

    @calmh
    Member

    It's actually somewhat fascinating, the CPU time is not doing GC but just setting up the bloom filters for the GC, something I'd expect to be pretty much instantaneous. Have you manually tweaked the interval for running GC? (--debug-db-indirect-gc-interval or $STGCINDIRECTEVERY)

  5. zhengran14 commented on Jan 17, 2025

    @zhengran14
    Author

    It's actually somewhat fascinating, the CPU time is not doing GC but just setting up the bloom filters for the GC, something I'd expect to be pretty much instantaneous. Have you manually tweaked the interval for running GC? (--debug-db-indirect-gc-interval or $STGCINDIRECTEVERY)

    Did not use these.

  6. camoz commented on May 8, 2025

    @camoz

    Having the same or a similar issue on Linux with syncthing v1.29.6, where it would use a lot of CPU for long times, and a restart of syncthing immediately fixes it. I recently upgraded from v1.29.3 and don't remember having this issue before, I could be wrong though. I don't know if it cures itself after sometime, because I just restart it, because my fan becomes so loud (Ivy Bridge laptop)... Edit: Like OP, I have this issue while syncthing is not actively syncing anything, the Web GUI shows everything "Up to date".

  7. calmh commented on May 9, 2025

    @calmh
    Member

    Take a CPU profile please, or there is nothing to debug.

  8. camoz commented on May 14, 2025

    @camoz

    Here are four CPU profiles from today (not from the Ivy Bridge laptop mentioned above, a slightly newer laptop). The CPU profiles were taken at a time where the CPU usage was high due to syncthing, everything was showing "Up to date" i.e. no active syncing, and nothing else noteworthy was running on the laptop.

    In case it matters, here is how I have syncthing configured:

    • Connections: set Sync Protocol Listen Addresses to tcp4://:22000, quic4://:22000
    • Connections: disable Enable NAT traversal, Global Discovery and Enable Relaying
    • Connections: enable Local Discovery
    • For most folders, I have set fsWatcherDelayS to 0.5 or 1
  9. calmh commented on May 23, 2025

    @calmh
    Member

    Those URLs are all errors for me

  10. camoz commented on May 23, 2025

    @camoz

    @calmh Please try again, I reuploaded. Maybe they got deleted in the meantime. (For some reason I cannot upload them directly here.)

  11. calmh commented on May 23, 2025

    @calmh
    Member

    Looks like it's reacting to lots and lots of filesystem notifications...

  12. camoz commented on May 23, 2025

    @camoz

    In case it's useful, here is some basic data about the two synced folders that I use on this device. There is one folder with 290 small files that never change. Apart from this one, no folder contains more than 150 files.

    Image

    Image

  13. calmh commented on May 24, 2025

    @calmh
    Member

    I think it's a bug in the watch aggregator where it thinks there are events to handle, but there aren't and it's just spinning. Combined with a very low FSWatcherDelayS set on the folder?

    Adding the above profiles for stable storage:

    profiles.zip

  14. removed
    needs-triage
    on May 24, 2025
  15. 7 remaining items

  16. AudriusButkevicius commented on Jun 12, 2025

    @AudriusButkevicius
    Member

    I'm a bit lost, time.Duration is an int64, yet watcher delay is float, anything sub 1s gets rounded down to 0, so you just end up going into an infinite loop.

    https://go.dev/play/p/X3lB6DW8OKj

  17. imsodin commented on Jun 12, 2025

    @imsodin
    Member

    🤦

    Not much more to say here. The person who suggested the config change clearly did think this through:

    It might be mostly free to change the type to float and keep the seconds unit.

    With "mostly" doing some very heavy lifting here xD

  18. added 3 commits that reference this issue on Jun 13, 2025
    86be706
    9d43ea0
    f80f859
  19. added a commit that references this issue on Jun 13, 2025
    e4ab7b4
  20. added a commit that references this issue on Jun 15, 2025
    6a0c612
  21. added a commit that references this issue on Jun 29, 2025
    1f8ce43
  22. zhengran14 commented on Jun 30, 2025

    @zhengran14
    Author

    @calmh @imsodin In my case, I don't have any sync tasks also cpu high, is it possible that this bug could cause my situation as well?

    this is my (pprof) top:

          flat  flat%   sum%        cum   cum%
        1120ms 20.04% 20.04%     1120ms 20.04%  math.archExp
         970ms 17.35% 37.39%      970ms 17.35%  runtime.memclrNoHeapPointers
         520ms  9.30% 46.69%      530ms  9.48%  math.log1p
         230ms  4.11% 50.81%      230ms  4.11%  math.archLog
         210ms  3.76% 54.56%      780ms 13.95%  runtime.scanobject
         170ms  3.04% 57.60%      170ms  3.04%  runtime.(*mspan).base (inline)
         140ms  2.50% 60.11%     2160ms 38.64%  github.com/greatroar/blobloom.fpRate
         110ms  1.97% 62.08%      120ms  2.15%  runtime.findObject
         100ms  1.79% 63.86%      100ms  1.79%  runtime.futex
          90ms  1.61% 65.47%       90ms  1.61%  runtime.(*gcBits).bitp (inline)
    

    and (pprof) list github.com/greatroar/blobloom.fpRate:

    Total: 5.59s
    ROUTINE ======================== github.com/greatroar/blobloom.fpRate in github.com\greatroar\[email protected]\optimize.go
         140ms      2.16s (flat, cum) 38.64% of Total
             .          .    143:func fpRate(c, k float64) (p float64, iter int) {
             .          .    144:   switch {
             .          .    145:   case c == 0:
             .          .    146:           panic("0 bits per key is too few")
             .          .    147:   case k == 0:
             .          .    148:           panic("0 hashes is too few")
             .          .    149:   }
             .          .    150:
             .          .    151:   // Putze et al.'s Equation (3).
             .          .    152:   //
             .          .    153:   // The Poisson distribution has a single spike around its mean
             .          .    154:   // BlockBits/c that gets slimmer and further away from zero as c tends
             .          .    155:   // to zero (the Bloom filter gets more filled). We start at the mean,
             .          .    156:   // then add terms left and right of it until their relative contribution
             .          .    157:   // drops below ε.
             .          .    158:   const ε = 1e-9
             .          .    159:   mean := BlockBits / c
             .          .    160:
             .          .    161:   // Ceil to make sure we start at one, not zero.
             .          .    162:   i := math.Ceil(mean)
             .       70ms    163:   p = math.Exp(logPoisson(mean, i) + logFprBlock(BlockBits/i, k))
             .          .    164:
             .          .    165:   for j := i - 1; j > 0; j-- {
             .      670ms    166:           add := math.Exp(logPoisson(mean, j) + logFprBlock(BlockBits/j, k))
             .          .    167:           p += add
          40ms       40ms    168:           iter++
          30ms       30ms    169:           if add/p < ε {
             .          .    170:                   break
             .          .    171:           }
             .          .    172:   }
             .          .    173:
             .          .    174:   for j := i + 1; ; j++ {
          20ms      1.30s    175:           add := math.Exp(logPoisson(mean, j) + logFprBlock(BlockBits/j, k))
             .          .    176:           p += add
             .          .    177:           iter++
          50ms       50ms    178:           if add/p < ε {
             .          .    179:                   break
             .          .    180:           }
             .          .    181:   }
             .          .    182:
             .          .    183:   return p, iter
    
  23. added a commit that references this issue on Jul 5, 2025
    e968c74
  24. added this to the v2.0.0 milestone on Aug 12, 2025
  25. added
    frozen-due-to-age
    on Jul 1, 2026
  26. locked and limited conversation to collaborators on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrozen-due-to-age

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions