Skip to content

Conversation

@ppca
Copy link
Contributor

@ppca ppca commented Aug 5, 2025

No description provided.

@ppca ppca requested a review from Copilot August 5, 2025 01:17
Copy link
Contributor

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 modifies the block processing logic to skip unnecessary operations when no new block heads are available. The change prevents the code from attempting to receive block heads when the receiver queue is empty, improving efficiency.

  • Restructures the conditional logic to check if the receiver queue is empty first
  • Adds an early continue statement when no block heads are available
  • Maintains the existing 60-second timeout warning functionality

tracing::warn!("No new block heads received for 60 seconds, waiting...");
receiver_state_update_timestamp = Instant::now();
}
continue;
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The continue statement will skip the block_heads_rx.recv().await call entirely when the queue is empty, but this creates a busy loop that consumes CPU unnecessarily. The original logic allowed the recv().await call to block and wait for new messages, which is more efficient than continuously polling.

Copilot uses AI. Check for mistakes.
@ppca ppca requested review from ChaoticTempest and volovyks August 5, 2025 20:43
@ChaoticTempest
Copy link
Contributor

why are we having interval.tick() at all? Do you just want to log that we haven't received anything for after a certain period of time?

If so, we can just do it in a tokio::select so that we don't need to poll as fast just to check if a block is ready or not since our warning is every 60s. We can probably just do 20s, and leave it up to the runtime to wake the recv when a new block is ready.

let mut interval = tokio::time::interval(Duration::from_secs(20));

tokio::select! {
    _ = interval.tick() => {
         if update.elapsed() > Duration::from_secs(60) { ... }
    }
    block_heads.recv() => {
        ...
    }
}

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