Search code examples
clinuxdebuggingdaemondaemons

When daemon will hog cpu?


What are the possible condition might occur for daemon to hog the cpu and makes the system very slow or moved to non-responsive state?

Daemons have few threads as well.


Solution

  • A tiny fraction of reasons include:

    • infinite loops in general
    • low memory in general
    • race conditions
    • dead locks
    • starvation
    • spawning too many threads
    • forking too much
    • super low process priority
    • infinite recursion
    • algorithms of bad algorithmic complexity
    • really slow operations on numbers
    • something is repeated too often (e.g. a variable that is better calculated outside a loop which the compiler was unable to move out)
    • cache-unfriendliness
    • using sleep-like functions
    • invoking slow functions
    • running the daemon on a slow machine
    • your are being DOS-attacked
    • your machine is running out of electricity and tries to slow down
    • your CPU has a bug
    • your CPU has a hardware defect
    • your CPU is running at too low voltage

    These list items are not exclusive to each other. We really can't tell something more specific without more information.