From b39364f087a643a9684dad2e03f089ba5cf6ac38 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Tue, 5 Nov 2024 16:03:22 +0700 Subject: [PATCH] svm: introduce filter_executable_us metric (#3472) Split the time taken by filter_executable_accounts() outside of program_cache_us. Filtering takes a considerable amount of time because account_matches_owners is pretty slow. --- svm/src/transaction_processor.rs | 12 ++++++++---- timings/src/lib.rs | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 5cd0c4f602a4bd..2f92d376152363 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -279,13 +279,15 @@ impl TransactionBatchProcessor { &mut error_metrics )); - let (mut program_cache_for_tx_batch, program_cache_us) = measure_us!({ - let mut program_accounts_map = Self::filter_executable_program_accounts( + let (mut program_accounts_map, filter_executable_us) = + measure_us!(Self::filter_executable_program_accounts( callbacks, sanitized_txs, &validation_results, - PROGRAM_OWNERS, - ); + PROGRAM_OWNERS + )); + + let (mut program_cache_for_tx_batch, program_cache_us) = measure_us!({ for builtin_program in self.builtin_program_ids.read().unwrap().iter() { program_accounts_map.insert(*builtin_program, 0); } @@ -385,6 +387,8 @@ impl TransactionBatchProcessor { execute_timings .saturating_add_in_place(ExecuteTimingType::ValidateFeesUs, validate_fees_us); + execute_timings + .saturating_add_in_place(ExecuteTimingType::FilterExecutableUs, filter_executable_us); execute_timings .saturating_add_in_place(ExecuteTimingType::ProgramCacheUs, program_cache_us); execute_timings.saturating_add_in_place(ExecuteTimingType::LoadUs, load_accounts_us); diff --git a/timings/src/lib.rs b/timings/src/lib.rs index 46878559eb25cc..2cd7a498040de9 100644 --- a/timings/src/lib.rs +++ b/timings/src/lib.rs @@ -57,6 +57,7 @@ pub enum ExecuteTimingType { UpdateTransactionStatuses, ProgramCacheUs, CheckBlockLimitsUs, + FilterExecutableUs, } pub struct Metrics([u64; ExecuteTimingType::CARDINALITY]); @@ -107,6 +108,13 @@ eager_macro_rules! { $eager_1 .index(ExecuteTimingType::ValidateFeesUs), i64 ), + ( + "filter_executable_us", + *$self + .metrics + .index(ExecuteTimingType::FilterExecutableUs), + i64 + ), ( "program_cache_us", *$self