diff --git a/core/src/banking_stage/latest_unprocessed_votes.rs b/core/src/banking_stage/latest_unprocessed_votes.rs index b201b786f3ec3f..7770db3a7ebacc 100644 --- a/core/src/banking_stage/latest_unprocessed_votes.rs +++ b/core/src/banking_stage/latest_unprocessed_votes.rs @@ -146,6 +146,20 @@ pub(crate) struct VoteBatchInsertionMetrics { pub(crate) num_dropped_tpu: usize, } +impl VoteBatchInsertionMetrics { + pub fn total_dropped_packets(&self) -> usize { + self.num_dropped_gossip + self.num_dropped_tpu + } + + pub fn dropped_gossip_packets(&self) -> usize { + self.num_dropped_gossip + } + + pub fn dropped_tpu_packets(&self) -> usize { + self.num_dropped_tpu + } +} + #[derive(Debug)] pub struct LatestUnprocessedVotes { latest_vote_per_vote_pubkey: RwLock>>>, diff --git a/core/src/banking_stage/leader_slot_metrics.rs b/core/src/banking_stage/leader_slot_metrics.rs index 5eca7f60b611c1..605dea1ce8cc17 100644 --- a/core/src/banking_stage/leader_slot_metrics.rs +++ b/core/src/banking_stage/leader_slot_metrics.rs @@ -1,9 +1,9 @@ use { super::{ consumer::LeaderProcessedTransactionCounts, + latest_unprocessed_votes::VoteBatchInsertionMetrics, leader_slot_timing_metrics::{LeaderExecuteAndCommitTimings, LeaderSlotTimingMetrics}, packet_deserializer::PacketReceiverStats, - vote_storage::InsertPacketBatchSummary, }, solana_poh::poh_recorder::BankStart, solana_sdk::{clock::Slot, saturating_add_assign}, @@ -688,18 +688,18 @@ impl LeaderSlotMetricsTracker { } } - pub(crate) fn accumulate_insert_packet_batches_summary( + pub(crate) fn accumulate_vote_batch_insertion_metrics( &mut self, - insert_packet_batches_summary: &InsertPacketBatchSummary, + vote_batch_insertion_metrics: &VoteBatchInsertionMetrics, ) { self.increment_exceeded_buffer_limit_dropped_packets_count( - insert_packet_batches_summary.total_dropped_packets() as u64, + vote_batch_insertion_metrics.total_dropped_packets() as u64, ); self.increment_dropped_gossip_vote_count( - insert_packet_batches_summary.dropped_gossip_packets() as u64, + vote_batch_insertion_metrics.dropped_gossip_packets() as u64, ); self.increment_dropped_tpu_vote_count( - insert_packet_batches_summary.dropped_tpu_packets() as u64 + vote_batch_insertion_metrics.dropped_tpu_packets() as u64 ); } diff --git a/core/src/banking_stage/packet_receiver.rs b/core/src/banking_stage/packet_receiver.rs index 3f592d7ab604b5..07b6be66c868db 100644 --- a/core/src/banking_stage/packet_receiver.rs +++ b/core/src/banking_stage/packet_receiver.rs @@ -143,12 +143,12 @@ impl PacketReceiver { slot_metrics_tracker .increment_newly_buffered_packets_count(deserialized_packets.len() as u64); - let insert_packet_batches_summary = vote_storage.insert_batch(deserialized_packets); + let vote_batch_insertion_metrics = vote_storage.insert_batch(deserialized_packets); slot_metrics_tracker - .accumulate_insert_packet_batches_summary(&insert_packet_batches_summary); + .accumulate_vote_batch_insertion_metrics(&vote_batch_insertion_metrics); saturating_add_assign!( *dropped_packets_count, - insert_packet_batches_summary.total_dropped_packets() + vote_batch_insertion_metrics.total_dropped_packets() ); } } diff --git a/core/src/banking_stage/vote_storage.rs b/core/src/banking_stage/vote_storage.rs index 47fc09447d5401..b2a37b50f63c63 100644 --- a/core/src/banking_stage/vote_storage.rs +++ b/core/src/banking_stage/vote_storage.rs @@ -38,39 +38,6 @@ pub struct VoteStorage { vote_source: VoteSource, } -#[derive(Debug)] -pub(crate) enum InsertPacketBatchSummary { - VoteBatchInsertionMetrics(VoteBatchInsertionMetrics), -} - -impl InsertPacketBatchSummary { - pub fn total_dropped_packets(&self) -> usize { - match self { - Self::VoteBatchInsertionMetrics(metrics) => { - metrics.num_dropped_gossip + metrics.num_dropped_tpu - } - } - } - - pub fn dropped_gossip_packets(&self) -> usize { - match self { - Self::VoteBatchInsertionMetrics(metrics) => metrics.num_dropped_gossip, - } - } - - pub fn dropped_tpu_packets(&self) -> usize { - match self { - Self::VoteBatchInsertionMetrics(metrics) => metrics.num_dropped_tpu, - } - } -} - -impl From for InsertPacketBatchSummary { - fn from(metrics: VoteBatchInsertionMetrics) -> Self { - Self::VoteBatchInsertionMetrics(metrics) - } -} - /// Convenient wrapper for shared-state between banking stage processing and the /// multi-iterator checking function. pub struct ConsumeScannerPayload<'a> { @@ -223,22 +190,20 @@ impl VoteStorage { pub(crate) fn insert_batch( &mut self, deserialized_packets: Vec, - ) -> InsertPacketBatchSummary { - InsertPacketBatchSummary::from( - self.latest_unprocessed_votes.insert_batch( - deserialized_packets - .into_iter() - .filter_map(|deserialized_packet| { - LatestValidatorVotePacket::new_from_immutable( - Arc::new(deserialized_packet), - self.vote_source, - self.latest_unprocessed_votes - .should_deprecate_legacy_vote_ixs(), - ) - .ok() - }), - false, // should_replenish_taken_votes - ), + ) -> VoteBatchInsertionMetrics { + self.latest_unprocessed_votes.insert_batch( + deserialized_packets + .into_iter() + .filter_map(|deserialized_packet| { + LatestValidatorVotePacket::new_from_immutable( + Arc::new(deserialized_packet), + self.vote_source, + self.latest_unprocessed_votes + .should_deprecate_legacy_vote_ixs(), + ) + .ok() + }), + false, // should_replenish_taken_votes ) }