High CPU usage (27-33%) when idle - busy-wait loop in sched_yield/futex

Resolved 💬 7 comments Opened Jan 9, 2026 by nazmulidris Closed Mar 5, 2026

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:

  1. sched_yield spam (5,980 calls) - Classic busy-wait: yielding CPU but immediately rescheduling
  2. futex contention (21,884 calls) - Heavy thread lock contention
  3. clock_gettime (5,222 calls) - Constant time polling
  4. statx (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

  1. Start claude in a terminal
  2. Let it sit idle at the prompt
  3. Observe CPU usage in top/htop or KDE System Monitor
  4. Run strace -p <pid> -c for 5 seconds to see syscall pattern

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗