Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Remove total_data_size and data_size_changed from `ExecuteDetails…
Browse files Browse the repository at this point in the history
…Timings` (#27051)

* Removes total_data_size and data_size_changed from ExecuteDetailsTimings.
  • Loading branch information
Lichtso authored Aug 23, 2022
1 parent 9b15749 commit b2ae7de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 57 deletions.
3 changes: 0 additions & 3 deletions program-runtime/src/pre_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ impl PreAccount {

if outermost_call {
timings.total_account_count = timings.total_account_count.saturating_add(1);
timings.total_data_size = timings.total_data_size.saturating_add(post.data().len());
if owner_changed
|| lamports_changed
|| data_len_changed
Expand All @@ -129,8 +128,6 @@ impl PreAccount {
|| self.changed
{
timings.changed_account_count = timings.changed_account_count.saturating_add(1);
timings.data_size_changed =
timings.data_size_changed.saturating_add(post.data().len());
}
}

Expand Down
17 changes: 0 additions & 17 deletions program-runtime/src/timings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,6 @@ eager_macro_rules! { $eager_1
$self.details.total_account_count,
i64
),
(
"execute_details_total_data_size",
$self.details.total_data_size,
i64
),
(
"execute_details_data_size_changed",
$self.details.data_size_changed,
i64
),
(
"execute_details_create_executor_register_syscalls_us",
$self
Expand Down Expand Up @@ -409,8 +399,6 @@ pub struct ExecuteDetailsTimings {
pub get_or_create_executor_us: u64,
pub changed_account_count: u64,
pub total_account_count: u64,
pub total_data_size: usize,
pub data_size_changed: usize,
pub create_executor_register_syscalls_us: u64,
pub create_executor_load_elf_us: u64,
pub create_executor_verify_code_us: u64,
Expand All @@ -430,8 +418,6 @@ impl ExecuteDetailsTimings {
);
saturating_add_assign!(self.changed_account_count, other.changed_account_count);
saturating_add_assign!(self.total_account_count, other.total_account_count);
saturating_add_assign!(self.total_data_size, other.total_data_size);
saturating_add_assign!(self.data_size_changed, other.data_size_changed);
saturating_add_assign!(
self.create_executor_register_syscalls_us,
other.create_executor_register_syscalls_us
Expand Down Expand Up @@ -547,15 +533,12 @@ mod tests {
let mut other_execute_details_timings =
construct_execute_timings_with_program(&program_id, us, compute_units_consumed);
let account_count = 1;
let data_size_changed = 1;
other_execute_details_timings.serialize_us = us;
other_execute_details_timings.create_vm_us = us;
other_execute_details_timings.execute_us = us;
other_execute_details_timings.deserialize_us = us;
other_execute_details_timings.changed_account_count = account_count;
other_execute_details_timings.total_account_count = account_count;
other_execute_details_timings.total_data_size = data_size_changed;
other_execute_details_timings.data_size_changed = data_size_changed;

// Accumulate the other instance into the current instance
execute_details_timings.accumulate(&other_execute_details_timings);
Expand Down
14 changes: 2 additions & 12 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4453,9 +4453,7 @@ impl Bank {
let ExecutionRecord {
accounts,
mut return_data,
changed_account_count,
total_size_of_all_accounts,
total_size_of_touched_accounts,
touched_account_count,
accounts_resize_delta,
} = transaction_context.into();
loaded_transaction.accounts = accounts;
Expand All @@ -4467,15 +4465,7 @@ impl Bank {
timings.details.total_account_count,
loaded_transaction.accounts.len() as u64
);
saturating_add_assign!(timings.details.changed_account_count, changed_account_count);
saturating_add_assign!(
timings.details.total_data_size,
total_size_of_all_accounts as usize
);
saturating_add_assign!(
timings.details.data_size_changed,
total_size_of_touched_accounts as usize
);
saturating_add_assign!(timings.details.changed_account_count, touched_account_count);
accounts_data_len_delta = status.as_ref().map_or(0, |_| accounts_resize_delta);
}

Expand Down
32 changes: 7 additions & 25 deletions sdk/src/transaction_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,38 +891,22 @@ impl<'a> BorrowedAccount<'a> {
pub struct ExecutionRecord {
pub accounts: Vec<TransactionAccount>,
pub return_data: TransactionReturnData,
pub changed_account_count: u64,
pub total_size_of_all_accounts: u64,
pub total_size_of_touched_accounts: u64,
pub touched_account_count: u64,
pub accounts_resize_delta: i64,
}

/// Used by the bank in the runtime to write back the processed accounts and recorded instructions
impl From<TransactionContext> for ExecutionRecord {
fn from(context: TransactionContext) -> Self {
let mut changed_account_count = 0u64;
let mut total_size_of_all_accounts = 0u64;
let mut total_size_of_touched_accounts = 0u64;
let account_touched_flags = context
.account_touched_flags
.try_borrow()
.expect("borrowing transaction_context.account_touched_flags failed");
for (index_in_transaction, was_touched) in account_touched_flags.iter().enumerate() {
let account_data_size = context
.get_account_at_index(index_in_transaction)
.expect("index_in_transaction out of bounds")
.try_borrow()
.expect("borrowing a transaction_context.account failed")
.data()
.len() as u64;
total_size_of_all_accounts =
total_size_of_all_accounts.saturating_add(account_data_size);
if *was_touched {
changed_account_count = changed_account_count.saturating_add(1);
total_size_of_touched_accounts =
total_size_of_touched_accounts.saturating_add(account_data_size);
}
}
let touched_account_count = account_touched_flags
.iter()
.fold(0u64, |accumulator, was_touched| {
accumulator.saturating_add(*was_touched as u64)
});
Self {
accounts: Vec::from(Pin::into_inner(context.account_keys))
.into_iter()
Expand All @@ -933,9 +917,7 @@ impl From<TransactionContext> for ExecutionRecord {
)
.collect(),
return_data: context.return_data,
changed_account_count,
total_size_of_all_accounts,
total_size_of_touched_accounts,
touched_account_count,
accounts_resize_delta: RefCell::into_inner(context.accounts_resize_delta),
}
}
Expand Down

0 comments on commit b2ae7de

Please sign in to comment.