Skip to content

High CPU load prevention: cancellation safety for AsyncReceiver#52

Merged
bvscd merged 1 commit intorelease/node/v0.4.0from
fix_async
Apr 2, 2026
Merged

High CPU load prevention: cancellation safety for AsyncReceiver#52
bvscd merged 1 commit intorelease/node/v0.4.0from
fix_async

Conversation

@bvscd
Copy link
Copy Markdown
Collaborator

@bvscd bvscd commented Apr 2, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 2, 2026 14:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses high CPU load prevention by implementing cancellation-safe counter management in AsyncReceiver. The changes ensure that when async tasks are cancelled while awaiting, internal state is properly maintained to prevent busy-waiting loops that consume excessive CPU.

Changes:

  • Introduces SyncGuard struct to provide RAII-based cancellation-safe counter management that decrements even when futures are dropped
  • Modifies AsyncReceiver::pop() to use the guard instead of manual fetch_add/fetch_sub calls
  • Moves stats recording in QuicNode::query() to after successful query completion to only record completed queries

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/adnl/src/adnl/common.rs Adds SyncGuard struct and updates AsyncReceiver::pop() to use it for cancellation safety
src/adnl/src/quic/mod.rs Moves msg_stats.record() to after successful query response

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bvscd bvscd merged commit c5a43af into release/node/v0.4.0 Apr 2, 2026
9 checks passed
@bvscd bvscd deleted the fix_async branch April 2, 2026 15:12
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.

3 participants