Skip to content

Commit

Permalink
refactor: bank transaction counts (anza-xyz#2382)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored Aug 4, 2024
1 parent 96deb8b commit ccabfcf
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 249 deletions.
14 changes: 2 additions & 12 deletions core/src/banking_stage/committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ impl Committer {
bank: &Arc<Bank>,
pre_balance_info: &mut PreBalanceInfo,
execute_and_commit_timings: &mut LeaderExecuteAndCommitTimings,
signature_count: u64,
executed_transactions_count: usize,
executed_non_vote_transactions_count: usize,
executed_with_successful_result_count: usize,
execution_counts: &ExecutedTransactionCounts,
) -> (u64, Vec<CommitTransactionDetails>) {
let executed_transactions = execution_results
.iter()
Expand All @@ -90,14 +87,7 @@ impl Committer {
execution_results,
last_blockhash,
lamports_per_signature,
ExecutedTransactionCounts {
executed_transactions_count: executed_transactions_count as u64,
executed_non_vote_transactions_count: executed_non_vote_transactions_count as u64,
executed_with_failure_result_count: executed_transactions_count
.saturating_sub(executed_with_successful_result_count)
as u64,
signature_count,
},
execution_counts,
&mut execute_and_commit_timings.execute_timings,
));
execute_and_commit_timings.commit_us = commit_time_us;
Expand Down
32 changes: 18 additions & 14 deletions core/src/banking_stage/consume_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ impl ConsumeWorkerMetrics {
fn update_on_execute_and_commit_transactions_output(
&self,
ExecuteAndCommitTransactionsOutput {
transactions_attempted_execution_count,
executed_transactions_count,
executed_with_successful_result_count,
transaction_counts,
retryable_transaction_indexes,
execute_and_commit_timings,
error_counters,
Expand All @@ -237,13 +235,19 @@ impl ConsumeWorkerMetrics {
) {
self.count_metrics
.transactions_attempted_execution_count
.fetch_add(*transactions_attempted_execution_count, Ordering::Relaxed);
.fetch_add(
transaction_counts.attempted_execution_count,
Ordering::Relaxed,
);
self.count_metrics
.executed_transactions_count
.fetch_add(*executed_transactions_count, Ordering::Relaxed);
.fetch_add(transaction_counts.executed_count, Ordering::Relaxed);
self.count_metrics
.executed_with_successful_result_count
.fetch_add(*executed_with_successful_result_count, Ordering::Relaxed);
.fetch_add(
transaction_counts.executed_with_successful_result_count,
Ordering::Relaxed,
);
self.count_metrics
.retryable_transaction_count
.fetch_add(retryable_transaction_indexes.len(), Ordering::Relaxed);
Expand Down Expand Up @@ -406,25 +410,25 @@ impl ConsumeWorkerMetrics {
}

struct ConsumeWorkerCountMetrics {
transactions_attempted_execution_count: AtomicUsize,
executed_transactions_count: AtomicUsize,
executed_with_successful_result_count: AtomicUsize,
transactions_attempted_execution_count: AtomicU64,
executed_transactions_count: AtomicU64,
executed_with_successful_result_count: AtomicU64,
retryable_transaction_count: AtomicUsize,
retryable_expired_bank_count: AtomicUsize,
cost_model_throttled_transactions_count: AtomicUsize,
cost_model_throttled_transactions_count: AtomicU64,
min_prioritization_fees: AtomicU64,
max_prioritization_fees: AtomicU64,
}

impl Default for ConsumeWorkerCountMetrics {
fn default() -> Self {
Self {
transactions_attempted_execution_count: AtomicUsize::default(),
executed_transactions_count: AtomicUsize::default(),
executed_with_successful_result_count: AtomicUsize::default(),
transactions_attempted_execution_count: AtomicU64::default(),
executed_transactions_count: AtomicU64::default(),
executed_with_successful_result_count: AtomicU64::default(),
retryable_transaction_count: AtomicUsize::default(),
retryable_expired_bank_count: AtomicUsize::default(),
cost_model_throttled_transactions_count: AtomicUsize::default(),
cost_model_throttled_transactions_count: AtomicU64::default(),
min_prioritization_fees: AtomicU64::new(u64::MAX),
max_prioritization_fees: AtomicU64::default(),
}
Expand Down
Loading

0 comments on commit ccabfcf

Please sign in to comment.