diff --git a/runtime/src/prioritization_fee.rs b/runtime/src/prioritization_fee.rs index 3c225090278989..4b629111183ff8 100644 --- a/runtime/src/prioritization_fee.rs +++ b/runtime/src/prioritization_fee.rs @@ -13,9 +13,21 @@ struct PrioritizationFeeMetrics { // fee for this slot. relevant_writable_accounts_count: u64, + // Count of transactions that have non-zero prioritization fee. + prioritized_transactions_count: u64, + + // Count of transactions that have zero prioritization fee. + non_prioritized_transactions_count: u64, + // Total prioritization fees included in this slot. total_prioritization_fee: u64, + // The minimum prioritization fee of prioritized transactions in this slot. + min_prioritization_fee: Option, + + // The maximum prioritization fee of prioritized transactions in this slot. + max_prioritization_fee: u64, + // Accumulated time spent on tracking prioritization fee for each slot. total_update_elapsed_us: u64, } @@ -29,6 +41,23 @@ impl PrioritizationFeeMetrics { saturating_add_assign!(self.total_update_elapsed_us, val); } + fn update_prioritization_fee(&mut self, fee: u64) { + if fee == 0 { + saturating_add_assign!(self.non_prioritized_transactions_count, 1); + return; + } + + // update prioritized transaction fee metrics. + saturating_add_assign!(self.prioritized_transactions_count, 1); + + self.max_prioritization_fee = self.max_prioritization_fee.max(fee); + + self.min_prioritization_fee = Some( + self.min_prioritization_fee + .map_or(fee, |min_fee| min_fee.min(fee)), + ); + } + fn report(&self, slot: Slot) { datapoint_info!( "block_prioritization_fee", @@ -43,11 +72,31 @@ impl PrioritizationFeeMetrics { self.relevant_writable_accounts_count as i64, i64 ), + ( + "prioritized_transactions_count", + self.prioritized_transactions_count as i64, + i64 + ), + ( + "non_prioritized_transactions_count", + self.non_prioritized_transactions_count as i64, + i64 + ), ( "total_prioritization_fee", self.total_prioritization_fee as i64, i64 ), + ( + "min_prioritization_fee", + self.min_prioritization_fee.unwrap_or(0) as i64, + i64 + ), + ( + "max_prioritization_fee", + self.max_prioritization_fee as i64, + i64 + ), ( "total_update_elapsed_us", self.total_update_elapsed_us as i64, @@ -125,6 +174,7 @@ impl PrioritizationFee { self.metrics .accumulate_total_prioritization_fee(transaction_fee); + self.metrics.update_prioritization_fee(transaction_fee); }, "update_time", );