claude -r: 100% CPU for 20+ minutes when resuming a 12MB session (4801 lines)
Resolved 💬 3 comments Opened Feb 9, 2026 by xianlezheng Closed Feb 13, 2026
Summary
claude -r (resume last session) causes 100% CPU on the main thread for 20+ minutes when the session JSONL is ~12MB. The CLI is completely frozen during this time — no output, no prompt, no way to interact.
Environment
- Claude Code: 2.1.37
- macOS 15.3 (Darwin 25.2.0, arm64)
- Apple M2 Pro, 32 GB RAM
Reproduction
- Work in a session with ~247 user turns, tool calls that produce large outputs (backtest results, screenshots, etc.)
- Exit
claude -r- Observe: 100%+ CPU, no output for 20+ minutes
Session characteristics
File: 12.4 MB, 4801 lines
progress: 4041 messages
user: 247 messages (6.8 MB total — tool_results with large outputs)
assistant: 385 messages (0.6 MB)
system: 71 messages
Messages > 100KB: 11
Largest single message: 877 KB (tool_result containing base64 image)
Profiling data
/usr/bin/sample (5s, 3670 samples):
- 93% of samples in a single JIT-compiled JS function on the main thread
- All Bun Pool worker threads idle (
__ulock_wait2) - HTTP Client idle (
kevent64) - JSC GC scavenger intermittently calling
madvise
Resource usage during resume:
Elapsed CPU RSS CPU Time
08:00 102.9% 1,578 MB —
12:00 103.6% 1,344 MB 9:46
16:00 102.1% 1,104 MB 12:02
20:00 108.2% 1,401 MB 16:40
RSS oscillates 1.1–1.6 GB (GC churn). Terminal I/O offset stays constant at ~5.3 MB — no rendering happening, pure CPU computation.
Expected
Resume a 12 MB session in seconds, not 20+ minutes.
Possible causes
- Full synchronous JSONL parse + deserialization on the main thread
- No streaming/incremental parsing — 877 KB base64 image payloads are fully materialized
- Conversation tree reconstruction scales poorly with message count
Suggestions
- Stream-parse JSONL incrementally, skip/truncate large tool_result payloads
- Offload parsing to a worker thread
- Show a progress indicator during load
- Auto-compact sessions exceeding a size threshold
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗