Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optimize] Process batch proposal transmissions using rayon #3149

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions node/bft/src/primary.rs
Expand Up @@ -58,6 +58,7 @@ use colored::Colorize;
use futures::stream::{FuturesUnordered, StreamExt};
use indexmap::{IndexMap, IndexSet};
use parking_lot::{Mutex, RwLock};
use rayon::prelude::*;
use std::{
collections::{HashMap, HashSet},
future::Future,
Expand Down Expand Up @@ -572,12 +573,12 @@ impl<N: Network> Primary<N> {
let mut transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?;

// Check that the transmission ids match and are not fee transactions.
for (transmission_id, transmission) in transmissions.iter_mut() {
if let Err(err) = cfg_iter_mut!(transmissions).try_for_each(|(transmission_id, transmission)| {
// If the transmission is not well-formed, then return early.
if let Err(err) = self.ledger.ensure_transmission_is_well_formed(*transmission_id, transmission) {
debug!("Batch propose from '{peer_ip}' contains an invalid transmission - {err}",);
return Ok(());
}
self.ledger.ensure_transmission_is_well_formed(*transmission_id, transmission)
}) {
debug!("Batch propose from '{peer_ip}' contains an invalid transmission - {err}",);
return Ok(());
}

// Ensure the batch is for the current round.
Expand Down