From eb06bb61e83570d33b787c868c960377ec5cb1da Mon Sep 17 00:00:00 2001 From: apfitzge Date: Fri, 19 Aug 2022 15:16:56 -0500 Subject: [PATCH] banking stage: actually aggregate tracer packet stats (#27118) * aggregated_tracer_packet_stats_option was alwasys None * Actually accumulate tracer packet stats --- core/src/banking_stage.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 83eae7330de1e4..2ec79c951675d7 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -2000,26 +2000,26 @@ impl BankingStage { packet_count_upperbound: usize, ) -> Result<(Vec, Option), RecvTimeoutError> { let start = Instant::now(); - let mut aggregated_tracer_packet_stats_option: Option = None; - let (mut packet_batches, new_tracer_packet_stats_option) = + let (mut packet_batches, mut aggregated_tracer_packet_stats_option) = verified_receiver.recv_timeout(recv_timeout)?; - if let Some(new_tracer_packet_stats) = &new_tracer_packet_stats_option { - if let Some(aggregated_tracer_packet_stats) = &mut aggregated_tracer_packet_stats_option - { - aggregated_tracer_packet_stats.aggregate(new_tracer_packet_stats); - } else { - aggregated_tracer_packet_stats_option = new_tracer_packet_stats_option; - } - } - let mut num_packets_received: usize = packet_batches.iter().map(|batch| batch.len()).sum(); - while let Ok((packet_batch, _tracer_packet_stats_option)) = verified_receiver.try_recv() { + while let Ok((packet_batch, tracer_packet_stats_option)) = verified_receiver.try_recv() { trace!("got more packet batches in banking stage"); let (packets_received, packet_count_overflowed) = num_packets_received .overflowing_add(packet_batch.iter().map(|batch| batch.len()).sum()); packet_batches.extend(packet_batch); + if let Some(tracer_packet_stats) = &tracer_packet_stats_option { + if let Some(aggregated_tracer_packet_stats) = + &mut aggregated_tracer_packet_stats_option + { + aggregated_tracer_packet_stats.aggregate(tracer_packet_stats); + } else { + aggregated_tracer_packet_stats_option = tracer_packet_stats_option; + } + } + // Spend any leftover receive time budget to greedily receive more packet batches, // until the upperbound of the packet count is reached. if start.elapsed() >= recv_timeout