Skip to content

Conversation

@bedwards
Copy link

The request_handler was cloning state.waiter inside the loop on each iteration. Since the source receiver never updates its "seen version", each clone immediately sees the current value as "new", causing changed() to return instantly and creating a hot loop (150%+ CPU).

Fix: Clone the receiver once before the loop, matching the correct pattern already used in dud_proxy_loop.

Also adds CLAUDE.md with project documentation for Claude Code.

🤖 Generated with Claude Code

bedwards and others added 5 commits December 26, 2025 08:39
The request_handler was cloning state.waiter inside the loop on each
iteration. Since the source receiver never updates its "seen version",
each clone immediately sees the current value as "new", causing
changed() to return instantly and creating a hot loop (150%+ CPU).

Fix: Clone the receiver once before the loop, matching the correct
pattern already used in dud_proxy_loop.

Also adds CLAUDE.md with project documentation for Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ndling

Performance improvements:

1. dud_proxy_loop: Replace busy-wait exit.is_empty() loop with
   tokio::select! to properly wait on exit signal OR new work.
   This eliminates CPU spinning when waiting for tasks.

2. Replace unbounded channels with bounded channels (capacity 1).
   Each tool call expects exactly one response, so capacity 1 is
   sufficient. Provides backpressure and prevents memory growth.

3. Replace panic-inducing unwraps with proper error handling:
   - Use let-else pattern for missing IDs
   - Use Option::is_err() checks instead of unwrap()
   - Add structured logging with tracing macros

4. Release lock before async channel send in response_handler
   to reduce lock contention.

5. Remove unnecessary Clone derive from RunCommandResponse.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instructions for installing from source on a new machine,
including Claude Code, Claude Desktop, and Cursor configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added header explaining this is a fork with performance fixes.
Documented all changes from upstream and maintainer contact info.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Added section to remove official release (kill processes, remove binaries, clean configs)
- Added CPU verification section to confirm fix is working
- Clarified this fork fixes critical 150%+ CPU bug

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant