Per-program id timings (#17554)

This commit is contained in:
sakridge 2021-06-04 16:04:31 +02:00 committed by GitHub
parent 60b0a13444
commit f97ce2cd7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 19 deletions

View File

@ -104,6 +104,27 @@ impl ReplaySlotStats {
i64 i64
), ),
); );
let mut per_pubkey_timings: Vec<_> = self
.execute_timings
.details
.per_program_timings
.iter()
.collect();
per_pubkey_timings.sort_by(|a, b| b.1 .0.cmp(&a.1 .0));
let total: u64 = per_pubkey_timings.iter().map(|a| a.1 .0).sum();
for (pubkey, time) in per_pubkey_timings.iter().take(5) {
datapoint_info!(
"per_program_timings",
("pubkey", pubkey.to_string(), String),
("execute_us", time.0, i64)
);
}
datapoint_info!(
"per_program_timings",
("pubkey", "all", String),
("execute_us", total, i64)
);
} }
} }

View File

@ -4,6 +4,7 @@ use crate::{
}; };
use log::*; use log::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use solana_measure::measure::Measure;
use solana_sdk::{ use solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount}, account::{AccountSharedData, ReadableAccount, WritableAccount},
account_utils::StateMut, account_utils::StateMut,
@ -63,6 +64,7 @@ pub struct ExecuteDetailsTimings {
pub total_account_count: u64, pub total_account_count: u64,
pub total_data_size: usize, pub total_data_size: usize,
pub data_size_changed: usize, pub data_size_changed: usize,
pub per_program_timings: HashMap<Pubkey, (u64, u32)>,
} }
impl ExecuteDetailsTimings { impl ExecuteDetailsTimings {
@ -75,6 +77,11 @@ impl ExecuteDetailsTimings {
self.total_account_count += other.total_account_count; self.total_account_count += other.total_account_count;
self.total_data_size += other.total_data_size; self.total_data_size += other.total_data_size;
self.data_size_changed += other.data_size_changed; self.data_size_changed += other.data_size_changed;
for (id, other) in &other.per_program_timings {
let time_count = self.per_program_timings.entry(*id).or_default();
time_count.0 += other.0;
time_count.1 += other.1;
}
} }
} }
@ -1205,28 +1212,38 @@ impl MessageProcessor {
) -> Result<(), TransactionError> { ) -> Result<(), TransactionError> {
let demote_sysvar_write_locks = feature_set.is_active(&demote_sysvar_write_locks::id()); let demote_sysvar_write_locks = feature_set.is_active(&demote_sysvar_write_locks::id());
for (instruction_index, instruction) in message.instructions.iter().enumerate() { for (instruction_index, instruction) in message.instructions.iter().enumerate() {
let mut time = Measure::start("execute_instruction");
let instruction_recorder = instruction_recorders let instruction_recorder = instruction_recorders
.as_ref() .as_ref()
.map(|recorders| recorders[instruction_index].clone()); .map(|recorders| recorders[instruction_index].clone());
self.execute_instruction( let err = self
message, .execute_instruction(
instruction, message,
&loaders[instruction_index], instruction,
accounts, &loaders[instruction_index],
account_deps, accounts,
rent_collector, account_deps,
log_collector.clone(), rent_collector,
executors.clone(), log_collector.clone(),
instruction_recorder, executors.clone(),
instruction_index, instruction_recorder,
feature_set.clone(), instruction_index,
bpf_compute_budget, feature_set.clone(),
timings, bpf_compute_budget,
demote_sysvar_write_locks, timings,
account_db.clone(), demote_sysvar_write_locks,
ancestors, account_db.clone(),
) ancestors,
.map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?; )
.map_err(|err| TransactionError::InstructionError(instruction_index as u8, err));
time.stop();
let program_id = instruction.program_id(&message.account_keys);
let time_count = timings.per_program_timings.entry(*program_id).or_default();
time_count.0 += time.as_us();
time_count.1 += 1;
err?;
} }
Ok(()) Ok(())
} }