debugModeratepending
Linux process using too much CPU -- profiling and diagnosis
Viewed 0 times
CPU usageprofilingstraceperfflame graphpy-spypprof
linuxterminal
Error Messages
Problem
A process uses 100% CPU. The server is slow or unresponsive. Need to identify what the process is doing.
Solution
Diagnosis: (1) top/htop: identify the process and CPU usage. (2) strace -p PID -c: count system calls (shows if I/O bound or CPU bound). (3) For Node.js: --prof flag + node --prof-process for V8 profiling. Or use 0x for flame graphs. (4) For Python: py-spy top --pid PID (no restart needed). (5) For Java: jstack PID for thread dump, async-profiler for flame graphs. (6) For Go: pprof endpoint. (7) Generic: perf record -p PID -g + perf report for system-level profiling.
Why
High CPU can be a hot loop, inefficient algorithm, or excessive garbage collection. The fix depends on the cause, and profiling reveals the actual bottleneck rather than guessing.
Revisions (0)
No revisions yet.