Skip to content

perf(daemon): early-out in note_output_sent_to_local_receivers when no deadlines/breakers - #2845

Merged
trunk-io[bot] merged 1 commit into
mainfrom
claude/dreamy-bardeen-90d0pc-output-sent-early-out
Jul 28, 2026
Merged

perf(daemon): early-out in note_output_sent_to_local_receivers when no deadlines/breakers#2845
trunk-io[bot] merged 1 commit into
mainfrom
claude/dreamy-bardeen-90d0pc-output-sent-early-out

Conversation

@phil-opp

Copy link
Copy Markdown
Collaborator

Issue

note_output_sent_to_local_receivers runs on every OutputSent message (the per-output notification). Its per-receiver loop has two possible effects:

  • refreshing an input deadline — only when input_deadlines is non-empty, and
  • circuit-breaker recovery — only when broken_inputs is non-empty.

Both inner branches already guard on those maps being non-empty. But in the common case where neither input_timeout deadlines nor circuit breakers are configured, the whole loop is a no-op — yet the function still did an Instant::now() clock read and, for every receiver, a subscribe_channels lookup plus a channel-capacity check, on every message.

Fix

Add a single early return at the top of the function when both input_deadlines and broken_inputs are empty, skipping the clock read and the entire loop. Behavior is unchanged: the loop had no observable effect in that case.

Validation

  • cargo test -p dora-daemon passes, including the existing note_output_sent recovery tests — those configure broken_inputs, so they still exercise the loop past the new guard.
  • cargo clippy ... -D warnings and cargo fmt --all --check pass.

⚠️ This PR is machine-generated by Claude (Claude Code), an AI assistant. Please review carefully before merging.

🤖 Generated with Claude Code

https://claude.ai/code/session_01D2eu6P1CvTvoKdK9fK3ZSd


Generated by Claude Code

…o deadlines/breakers

`note_output_sent_to_local_receivers` runs on every `OutputSent` message.
Its per-receiver loop has two possible effects: refreshing an input
deadline (only when `input_deadlines` is non-empty) and circuit-breaker
recovery (only when `broken_inputs` is non-empty). Both inner branches
already guard on those maps being non-empty.

In the common case where neither `input_timeout` deadlines nor circuit
breakers are configured, the whole loop is a no-op — yet the function still
did an `Instant::now()` clock read and a `subscribe_channels` lookup plus a
channel-capacity check for every receiver, on every message.

Add a single early return when both maps are empty, skipping the clock read
and the entire loop. Behavior is unchanged: the loop had no observable
effect in that case.

Validation: `cargo test -p dora-daemon` (including the existing
`note_output_sent` recovery tests, which configure `broken_inputs` and so
still exercise the loop), `cargo clippy`, and `cargo fmt --check` pass.

This change was generated by Claude (Claude Code), an AI assistant. It is
machine-generated and should be reviewed carefully before merging.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2eu6P1CvTvoKdK9fK3ZSd
@trunk-io

trunk-io Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

😎 Merged successfully - details.

Copy link
Copy Markdown
Collaborator Author

🤖 Fully automated review by Claude — this review was generated end-to-end by an automated agent with no human vetting. Treat it accordingly.

No issues found.

I traced the full body of note_output_sent_to_local_receivers (binaries/daemon/src/lib.rs:5283-5399). The per-receiver loop has exactly two effects, and both are already independently gated: the deadline refresh on !dataflow.input_deadlines.is_empty() (line 5326) and the circuit-breaker recovery on dataflow.broken_inputs.is_empty() (the continue at line 5350). When both maps are empty the loop performs no observable work, so the added if dataflow.input_deadlines.is_empty() && dataflow.broken_inputs.is_empty() { return; } is behavior-preserving — it also correctly skips the now-unused Instant::now() read, which is only consumed inside those two gated branches. The input_deadlines.insert(...) inside the recovery path (line 5374) is only reachable when broken_inputs is non-empty, so the early return never bypasses it.


Generated by Claude Code

@phil-opp
phil-opp marked this pull request as ready for review July 28, 2026 10:41
@trunk-io
trunk-io Bot merged commit 323e316 into main Jul 28, 2026
27 checks passed
@trunk-io
trunk-io Bot deleted the claude/dreamy-bardeen-90d0pc-output-sent-early-out branch July 28, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants