-
Notifications
You must be signed in to change notification settings - Fork 1k
block-prioritization-fee metrics update #6967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| use { | ||
| crate::{bank::Bank, prioritization_fee::*}, | ||
| crate::{bank::Bank, prioritization_fee::PrioritizationFee}, | ||
| crossbeam_channel::{unbounded, Receiver, Sender, TryRecvError}, | ||
| log::*, | ||
| solana_accounts_db::account_locks::validate_account_locks, | ||
|
|
@@ -47,6 +47,9 @@ struct PrioritizationFeeCacheMetrics { | |
|
|
||
| // Accumulated time spent on finalizing block prioritization fees. | ||
| total_block_finalize_elapsed_us: AtomicU64, | ||
|
|
||
| // Accumulated time spent on calculate transaction fees. | ||
| total_calculate_prioritization_fee_elapsed_us: AtomicU64, | ||
| } | ||
|
|
||
| impl PrioritizationFeeCacheMetrics { | ||
|
|
@@ -80,6 +83,11 @@ impl PrioritizationFeeCacheMetrics { | |
| .fetch_add(val, Ordering::Relaxed); | ||
| } | ||
|
|
||
| fn accumulate_total_calculate_prioritization_fee_elapsed_us(&self, val: u64) { | ||
| self.total_calculate_prioritization_fee_elapsed_us | ||
| .fetch_add(val, Ordering::Relaxed); | ||
| } | ||
|
|
||
| fn report(&self, slot: Slot) { | ||
| datapoint_info!( | ||
| "block_prioritization_fee_counters", | ||
|
|
@@ -117,6 +125,12 @@ impl PrioritizationFeeCacheMetrics { | |
| .swap(0, Ordering::Relaxed) as i64, | ||
| i64 | ||
| ), | ||
| ( | ||
| "total_calculate_prioritization_fee_elapsed_us", | ||
| self.total_calculate_prioritization_fee_elapsed_us | ||
| .swap(0, Ordering::Relaxed) as i64, | ||
| i64 | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -126,7 +140,8 @@ enum CacheServiceUpdate { | |
| TransactionUpdate { | ||
| slot: Slot, | ||
| bank_id: BankId, | ||
| transaction_fee: u64, | ||
| compute_unit_price: u64, | ||
| prioritization_fee: u64, | ||
| writable_accounts: Vec<Pubkey>, | ||
| }, | ||
| BankFinalized { | ||
|
|
@@ -233,11 +248,21 @@ impl PrioritizationFeeCache { | |
| .map(|(_, key)| *key) | ||
| .collect(); | ||
|
|
||
| let (prioritization_fee, calculate_prioritization_fee_us) = measure_us!({ | ||
| solana_fee_structure::FeeBudgetLimits::from(compute_budget_limits) | ||
| .prioritization_fee | ||
| }); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making additional fee calculation in hot path might be an issue, reporting its
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. metrics reported from devbox indicates near There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I don't like the additional work here. It's also worth noting that I've had a WIP PR to make See my other comment on reporting all fees.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I felt the same. Was focusing on Trent's particular use case, when one is curious about how cu-price is bidding up, it helps to put total fee collected as ref point. But yea, I don't love to have to calculate fee again here just for reporting. One benefit of reporting here vs from cost-tracking is, here only report when block is opportunistically confirmed. Wondering if adding fee to transaction meta is a good idea - I chatted about it before, don't remember why we didn't do it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but we won't report this on building nodes if we make prio-fee-cache optional (we should). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not separate infra, but the cost tracking is currently where we report other objective block facts around the cost. I feel it makes sense to just lop it near there for now so we have semething without reinventing a metric system. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i mostly want the separate infra 'cause 5000 identical datapoints is kinda useless load on the metrics db There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed, but i feel we should have this metric asap even if repeated. then can figure out how we want to report going forward separately, but don't lose data time
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. Do we have objection of reporting Can add total transaction fee reporting at Cost Tracker separately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's fine |
||
| self.metrics | ||
| .accumulate_total_calculate_prioritization_fee_elapsed_us( | ||
| calculate_prioritization_fee_us, | ||
| ); | ||
|
|
||
| self.sender | ||
| .send(CacheServiceUpdate::TransactionUpdate { | ||
| slot: bank.slot(), | ||
| bank_id: bank.bank_id(), | ||
| transaction_fee: compute_budget_limits.compute_unit_price, | ||
| compute_unit_price: compute_budget_limits.compute_unit_price, | ||
| prioritization_fee, | ||
| writable_accounts, | ||
| }) | ||
| .unwrap_or_else(|err| { | ||
|
|
@@ -271,7 +296,8 @@ impl PrioritizationFeeCache { | |
| unfinalized: &mut UnfinalizedPrioritizationFees, | ||
| slot: Slot, | ||
| bank_id: BankId, | ||
| transaction_fee: u64, | ||
| compute_unit_price: u64, | ||
| prioritization_fee: u64, | ||
| writable_accounts: Vec<Pubkey>, | ||
| metrics: &PrioritizationFeeCacheMetrics, | ||
| ) { | ||
|
|
@@ -280,7 +306,7 @@ impl PrioritizationFeeCache { | |
| .or_default() | ||
| .entry(bank_id) | ||
| .or_default() | ||
| .update(transaction_fee, writable_accounts)); | ||
| .update(compute_unit_price, prioritization_fee, writable_accounts)); | ||
| metrics.accumulate_total_entry_update_elapsed_us(entry_update_us); | ||
| metrics.accumulate_successful_transaction_update_count(1); | ||
| } | ||
|
|
@@ -374,13 +400,15 @@ impl PrioritizationFeeCache { | |
| CacheServiceUpdate::TransactionUpdate { | ||
| slot, | ||
| bank_id, | ||
| transaction_fee, | ||
| compute_unit_price, | ||
| prioritization_fee, | ||
| writable_accounts, | ||
| } => Self::update_cache( | ||
| &mut unfinalized, | ||
| slot, | ||
| bank_id, | ||
| transaction_fee, | ||
| compute_unit_price, | ||
| prioritization_fee, | ||
| writable_accounts, | ||
| &metrics, | ||
| ), | ||
|
|
@@ -414,7 +442,7 @@ impl PrioritizationFeeCache { | |
| .iter() | ||
| .map(|(slot, slot_prioritization_fee)| { | ||
| let mut fee = slot_prioritization_fee | ||
| .get_min_transaction_fee() | ||
| .get_min_compute_unit_price() | ||
| .unwrap_or_default(); | ||
| for account_key in account_keys { | ||
| if let Some(account_fee) = | ||
|
|
@@ -549,7 +577,7 @@ mod tests { | |
| sync_finalize_priority_fee_for_test(&prioritization_fee_cache, slot, bank.bank_id()); | ||
| let lock = prioritization_fee_cache.cache.read().unwrap(); | ||
| let fee = lock.get(&slot).unwrap(); | ||
| assert_eq!(2, fee.get_min_transaction_fee().unwrap()); | ||
| assert_eq!(2, fee.get_min_compute_unit_price().unwrap()); | ||
| assert!(fee.get_writable_account_fee(&write_account_a).is_none()); | ||
| assert_eq!(5, fee.get_writable_account_fee(&write_account_b).unwrap()); | ||
| assert!(fee.get_writable_account_fee(&write_account_c).is_none()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
min|max_compute_unit_prices are reported as sanitized raw value, inmicro-lamports; vs abovetotal_non_vote_transaction_feeis reported inlamports