High CPU usage (27-33%) when idle - busy-wait loop in sched_yield/futex
Summary
Claude Code consumes 27-33% of a CPU core when idle (waiting for user input), caused by a busy-wait loop pattern visible in syscall traces.
Environment
- OS: Fedora 43 (Linux 6.18.3)
- CPU: Intel Core i7-14700 (20 cores)
- Claude Code version: Latest (installed via
~/.local/bin/claude)
Observed Behavior
Multiple Claude Code instances running:
| PID | CPU % | Status |
|-----|-------|--------|
| 71457, 72589, 89061, 89978 | 0.3-0.4% | Truly idle (from previous day) |
| 614750 | 33.2% | "Active" but waiting for input |
| 946540 | 27.8% | "Active" but waiting for input |
The "active" instances are just sitting at a prompt, not processing anything.
Syscall Analysis
5-second strace on the 33% CPU process:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
49.68 0.046981 7 5980 sched_yield
33.58 0.031758 1 21884 165 futex
6.08 0.005754 1150 5 wait4
5.46 0.005159 3 1293 epoll_pwait2
1.52 0.001439 0 5222 clock_gettime
1.48 0.001402 0 2450 statx
0.73 0.000687 0 1078 madvise
...
------ ----------- ----------- --------- --------- ----------------
100.00 0.094562 2 41221 1134 total
41,221 syscalls in 5 seconds (~8,200/sec) for an idle process.
Analysis
The syscall pattern indicates:
sched_yieldspam (5,980 calls) - Classic busy-wait: yielding CPU but immediately reschedulingfutexcontention (21,884 calls) - Heavy thread lock contentionclock_gettime(5,222 calls) - Constant time pollingstatx(2,450 calls) - Frequent file stat checks (file watcher?)
This is busy-polling behavior - the process yields to be "nice" but immediately wakes up again instead of properly blocking on I/O.
Expected Behavior
Idle CPU usage should be <1% (similar to the 0.3-0.4% seen in truly idle instances from the previous day).
Impact
- Battery drain on laptops
- Unnecessary heat/power consumption on desktops
- Wasted CPU cycles that could be used for compilation or other tasks
Reproduction
- Start
claudein a terminal - Let it sit idle at the prompt
- Observe CPU usage in
top/htopor KDE System Monitor - Run
strace -p <pid> -cfor 5 seconds to see syscall pattern
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗