Skip to content

Commit

Permalink
Use batch_send in forward_buffered_packets (solana-labs#20330)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbiseda authored Sep 30, 2021
1 parent 94668c9 commit 3854cfa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use solana_sdk::{
timing::{duration_as_ms, timestamp, AtomicInterval},
transaction::{self, SanitizedTransaction, TransactionError, VersionedTransaction},
};
use solana_streamer::sendmmsg::{batch_send, SendPktsError};
use solana_transaction_status::token_balances::{
collect_token_balances, TransactionTokenBalancesSet,
};
Expand Down Expand Up @@ -375,11 +376,16 @@ impl BankingStage {
data_budget.update(INTERVAL_MS, |bytes| {
std::cmp::min(bytes + MAX_BYTES_PER_INTERVAL, MAX_BYTES_BUDGET)
});

let mut packet_vec = Vec::with_capacity(packets.len());
for p in packets {
if data_budget.take(p.meta.size) {
socket.send_to(&p.data[..p.meta.size], &tpu_forwards)?;
packet_vec.push((&p.data[..p.meta.size], tpu_forwards));
}
}
if let Err(SendPktsError::IoError(ioerr, _num_failed)) = batch_send(socket, &packet_vec) {
return Err(ioerr);
}

Ok(())
}
Expand Down

0 comments on commit 3854cfa

Please sign in to comment.