Skip to content

Commit

Permalink
Add metrics for min/max priority fee per slot, and counters for fee/n…
Browse files Browse the repository at this point in the history
…on-fee transactions (#29330)

* Add metrics for min/max priority fee per slot, and counters for fee/non-fee txs

* get fee range of prioritized transactions only

* Update runtime/src/prioritization_fee.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Update runtime/src/prioritization_fee.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* fix format

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
tao-stones and t-nelson authored Dec 21, 2022
1 parent 926debd commit 0244b01
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions runtime/src/prioritization_fee.rs
Original file line number Diff line number Diff line change
@@ -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<u64>,

// 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",
);

0 comments on commit 0244b01

Please sign in to comment.