Skip to content

Commit

Permalink
Remove saturating_add_assign from leader_slot_metrics (#4070)
Browse files Browse the repository at this point in the history
  • Loading branch information
roryharr authored Dec 13, 2024
1 parent 269cad0 commit 73289ca
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 73 deletions.
99 changes: 36 additions & 63 deletions core/src/banking_stage/leader_slot_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,10 @@ impl LeaderSlotMetricsTracker {
*cost_model_throttled_transactions_count
);

saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_packets_timings
.cost_model_us,
*cost_model_us
);
leader_slot_metrics
.timing_metrics
.process_packets_timings
.cost_model_us += cost_model_us;

leader_slot_metrics
.packet_count_metrics
Expand Down Expand Up @@ -995,98 +992,74 @@ impl LeaderSlotMetricsTracker {
// Processing buffer timing metrics
pub(crate) fn increment_make_decision_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.make_decision_us,
us
);
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.make_decision_us += us;
}
}

pub(crate) fn increment_consume_buffered_packets_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.consume_buffered_packets_us,
us
);
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.consume_buffered_packets_us += us;
}
}

pub(crate) fn increment_forward_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.forward_us,
us
);
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.forward_us += us;
}
}

pub(crate) fn increment_forward_and_hold_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.forward_and_hold_us,
us
);
leader_slot_metrics
.timing_metrics
.process_buffered_packets_timings
.forward_and_hold_us += us;
}
}

pub(crate) fn increment_process_packets_transactions_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.consume_buffered_packets_timings
.process_packets_transactions_us,
us
);
leader_slot_metrics
.timing_metrics
.consume_buffered_packets_timings
.process_packets_transactions_us += us
}
}

// Processing packets timing metrics
pub(crate) fn increment_transactions_from_packets_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_packets_timings
.transactions_from_packets_us,
us
);
leader_slot_metrics
.timing_metrics
.process_packets_timings
.transactions_from_packets_us += us;
}
}

pub(crate) fn increment_process_transactions_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_packets_timings
.process_transactions_us,
us
);
leader_slot_metrics
.timing_metrics
.process_packets_timings
.process_transactions_us += us;
}
}

pub(crate) fn increment_filter_retryable_packets_us(&mut self, us: u64) {
if let Some(leader_slot_metrics) = &mut self.leader_slot_metrics {
saturating_add_assign!(
leader_slot_metrics
.timing_metrics
.process_packets_timings
.filter_retryable_packets_us,
us
);
leader_slot_metrics
.timing_metrics
.process_packets_timings
.filter_retryable_packets_us += us;
}
}

Expand Down
18 changes: 8 additions & 10 deletions core/src/banking_stage/leader_slot_timing_metrics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use {
solana_poh::poh_recorder::RecordTransactionsTimings,
solana_sdk::{clock::Slot, saturating_add_assign},
solana_timings::ExecuteTimings,
std::time::Instant,
solana_poh::poh_recorder::RecordTransactionsTimings, solana_sdk::clock::Slot,
solana_timings::ExecuteTimings, std::time::Instant,
};

#[derive(Default, Debug)]
Expand All @@ -19,12 +17,12 @@ pub struct LeaderExecuteAndCommitTimings {

impl LeaderExecuteAndCommitTimings {
pub fn accumulate(&mut self, other: &LeaderExecuteAndCommitTimings) {
saturating_add_assign!(self.collect_balances_us, other.collect_balances_us);
saturating_add_assign!(self.load_execute_us, other.load_execute_us);
saturating_add_assign!(self.freeze_lock_us, other.freeze_lock_us);
saturating_add_assign!(self.record_us, other.record_us);
saturating_add_assign!(self.commit_us, other.commit_us);
saturating_add_assign!(self.find_and_send_votes_us, other.find_and_send_votes_us);
self.collect_balances_us += other.collect_balances_us;
self.load_execute_us += other.load_execute_us;
self.freeze_lock_us += other.freeze_lock_us;
self.record_us += other.record_us;
self.commit_us += other.commit_us;
self.find_and_send_votes_us += other.find_and_send_votes_us;
self.record_transactions_timings
.accumulate(&other.record_transactions_timings);
self.execute_timings.accumulate(&other.execute_timings);
Expand Down

0 comments on commit 73289ca

Please sign in to comment.