Skip to content

Commit

Permalink
Collapse InsertPacketBatchSummary into VoteBatchInsertionMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ksolana committed Feb 28, 2025
1 parent 5238366 commit 8b487c7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 58 deletions.
14 changes: 14 additions & 0 deletions core/src/banking_stage/latest_unprocessed_votes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashMap<Pubkey, Arc<RwLock<LatestValidatorVotePacket>>>>,
Expand Down
12 changes: 6 additions & 6 deletions core/src/banking_stage/leader_slot_metrics.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -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
);
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/banking_stage/packet_receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
}
Expand Down
63 changes: 14 additions & 49 deletions core/src/banking_stage/vote_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<VoteBatchInsertionMetrics> 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> {
Expand Down Expand Up @@ -223,22 +190,20 @@ impl VoteStorage {
pub(crate) fn insert_batch(
&mut self,
deserialized_packets: Vec<ImmutableDeserializedPacket>,
) -> 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
)
}

Expand Down

0 comments on commit 8b487c7

Please sign in to comment.