Skip to content

⚡ Bolt: Optimize circuit breaker fast path to prevent DashMap write lock contention - #80

Merged
ovasylenko merged 1 commit into
mainfrom
bolt/circuit-breaker-read-lock-12300898650048027779
Jul 6, 2026
Merged

⚡ Bolt: Optimize circuit breaker fast path to prevent DashMap write lock contention#80
ovasylenko merged 1 commit into
mainfrom
bolt/circuit-breaker-read-lock-12300898650048027779

Conversation

@ovasylenko

Copy link
Copy Markdown
Contributor

💡 What: Introduced a fast-path read lock using self.breakers.get(q) at the beginning of record_failure in the circuit breaker registry. If the breaker is already fully Open, it returns early instead of acquiring a write lock to increment the failure_count.
🎯 Why: During a failure storm, many in-flight requests may fail sequentially or concurrently. The previous implementation acquired a get_mut() write lock on the DashMap shard for every failure to increment the failure_count. However, once a circuit is Open, the failure_count has no behavioral impact on cooldown timers or recovery. Avoiding the write lock entirely removes severe contention on the specific DashMap shard.
📊 Impact: Completely eliminates write-lock contention on the hot path for failing services once their circuit is open, dramatically reducing CPU overhead during cascading failures.
🔬 Measurement: Verify via cargo check, cargo fmt, cargo clippy, and cargo test -p orch8-engine --lib circuit_breaker.


PR created automatically by Jules for task 12300898650048027779 started by @ovasylenko

…ock contention

Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@ovasylenko
ovasylenko merged commit 761f54d into main Jul 6, 2026
14 checks passed
ovasylenko added a commit that referenced this pull request Jul 6, 2026
PR #80 predates the edition-2024 if-let-chain style used elsewhere in
this file; clippy now flags the nested if as collapsible.
@ovasylenko
ovasylenko deleted the bolt/circuit-breaker-read-lock-12300898650048027779 branch July 16, 2026 00:10
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