[Bug] Busy-wait loop in event loop causing excessive CPU usage during idle

Resolved 💬 3 comments Opened Oct 28, 2025 by orgoj Closed Nov 1, 2025

Bug Description
Bug Report: Claude Processes Busy-Waiting with High CPU Usage

Environment

  • OS: Linux 6.14.0-33-generic
  • Claude version: Multiple instances running
  • System: 32GB RAM, ZFS storage

Problem Description

Two Claude processes consuming excessive CPU while appearing to wait for input:

  • PID 128071: 80.2% CPU (running since 09:11 in pts/11)
  • PID 165435: 62.2% CPU (running since 09:30 in pts/12)

Root Cause Analysis (strace output)

Both processes exhibit identical busy-waiting pattern:

epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
[repeats continuously...]

Key findings:

  1. Busy-wait loop: epoll_pwait() called with timeout=0 (non-blocking)
  2. No events available: Return value 0 indicates no events ready
  3. No backoff/sleep: Immediately calls epoll_pwait() again without delay
  4. Result: Tight CPU-spinning loop while waiting for I/O

Expected Behavior

epoll_pwait() should use timeout > 0 or timeout=-1 (blocking) to sleep when no events are available, yielding CPU to other processes.

Actual Behavior

Non-blocking epoll_pwait() with immediate retry creates busy-wait loop, consuming ~25% CPU per process while idle.

Additional Observations

  • Occasional bursts of activity (eventfd writes, futex operations)
  • Pattern suggests Node.js event loop misconfiguration
  • Multiple Claude instances show same behavior (~25 total processes)

Impact

  • Unnecessary CPU consumption while waiting for user input
  • Reduced battery life on laptops
  • Fan noise from sustained CPU load
  • System responsiveness degradation

Reproduction

Launch Claude Code session and let it wait for user input - CPU usage remains high instead of dropping to near-zero.

Environment Info

  • Platform: linux
  • Terminal: WezTerm
  • Version: 2.0.28
  • Feedback ID: bbf92fca-e36a-4b6f-ad4f-971a0cdcef76

Errors

[{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at YD (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:1175:4413)\n    at file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:1175:4141\n    at Array.map (<anonymous>)\n    at OF (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:1175:4132)\n    at YTQ (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:1797:6306)\n    at Vw (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:73:19414)\n    at Qo (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:75:42806)\n    at T9 (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:75:38347)\n    at zc (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:75:38275)\n    at Lw (file:///home/michael/.local/share/mise/installs/claude/2.0.28/lib/node_modules/@anthropic-ai/claude-code/cli.js:75:38129)","timestamp":"2025-10-28T09:05:29.742Z"}]

View original on GitHub ↗

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