Skip to content

Commit

Permalink
svm: introduce filter_executable_us metric (#3472)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alessandrod authored Nov 5, 2024
1 parent e7778eb commit b39364f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,15 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
&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);
}
Expand Down Expand Up @@ -385,6 +387,8 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {

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);
Expand Down
8 changes: 8 additions & 0 deletions timings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub enum ExecuteTimingType {
UpdateTransactionStatuses,
ProgramCacheUs,
CheckBlockLimitsUs,
FilterExecutableUs,
}

pub struct Metrics([u64; ExecuteTimingType::CARDINALITY]);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b39364f

Please sign in to comment.