Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track transaction performance track txn in banking stage deep #35402

Closed
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ members = [
"tokens",
"tpu-client",
"transaction-dos",
"transaction-metrics-tracker",
"transaction-status",
"turbine",
"udp-client",
Expand Down Expand Up @@ -378,6 +379,7 @@ solana-system-program = { path = "programs/system", version = "=1.19.0" }
solana-test-validator = { path = "test-validator", version = "=1.19.0" }
solana-thin-client = { path = "thin-client", version = "=1.19.0" }
solana-tpu-client = { path = "tpu-client", version = "=1.19.0", default-features = false }
solana-transaction-metrics-tracker = { path = "transaction-metrics-tracker", version = "=1.19.0" }
solana-transaction-status = { path = "transaction-status", version = "=1.19.0" }
solana-turbine = { path = "turbine", version = "=1.19.0" }
solana-udp-client = { path = "udp-client", version = "=1.19.0" }
Expand Down
29 changes: 14 additions & 15 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ use {
nonce_info::{NonceFull, NonceInfo},
pubkey::Pubkey,
slot_hashes::SlotHashes,
transaction::{Result, SanitizedTransaction, TransactionAccountLocks, TransactionError},
transaction::{
ExtendedSanitizedTransaction, Result, TransactionAccountLocks, TransactionError,
},
transaction_context::TransactionAccount,
},
solana_svm::{
account_loader::TransactionLoadResult, transaction_results::TransactionExecutionResult,
},
std::{
cmp::Reverse,
collections::{
hash_map::{self},
BinaryHeap, HashMap, HashSet,
},
collections::{hash_map, BinaryHeap, HashMap, HashSet},
ops::RangeBounds,
sync::{
atomic::{AtomicUsize, Ordering},
Expand Down Expand Up @@ -568,11 +567,11 @@ impl Accounts {
#[allow(clippy::needless_collect)]
pub fn lock_accounts<'a>(
&self,
txs: impl Iterator<Item = &'a SanitizedTransaction>,
txs: impl Iterator<Item = &'a ExtendedSanitizedTransaction>,
tx_account_lock_limit: usize,
) -> Vec<Result<()>> {
let tx_account_locks_results: Vec<Result<_>> = txs
.map(|tx| tx.get_account_locks(tx_account_lock_limit))
.map(|tx| tx.transaction.get_account_locks(tx_account_lock_limit))
.collect();
self.lock_accounts_inner(tx_account_locks_results)
}
Expand All @@ -581,14 +580,14 @@ impl Accounts {
#[allow(clippy::needless_collect)]
pub fn lock_accounts_with_results<'a>(
&self,
txs: impl Iterator<Item = &'a SanitizedTransaction>,
txs: impl Iterator<Item = &'a ExtendedSanitizedTransaction>,
results: impl Iterator<Item = Result<()>>,
tx_account_lock_limit: usize,
) -> Vec<Result<()>> {
let tx_account_locks_results: Vec<Result<_>> = txs
.zip(results)
.map(|(tx, result)| match result {
Ok(()) => tx.get_account_locks(tx_account_lock_limit),
Ok(()) => tx.transaction.get_account_locks(tx_account_lock_limit),
Err(err) => Err(err),
})
.collect();
Expand Down Expand Up @@ -618,13 +617,13 @@ impl Accounts {
#[allow(clippy::needless_collect)]
pub fn unlock_accounts<'a>(
&self,
txs: impl Iterator<Item = &'a SanitizedTransaction>,
txs: impl Iterator<Item = &'a ExtendedSanitizedTransaction>,
results: &[Result<()>],
) {
let keys: Vec<_> = txs
.zip(results)
.filter(|(_, res)| res.is_ok())
.map(|(tx, _)| tx.get_account_locks_unchecked())
.map(|(tx, _)| tx.transaction.get_account_locks_unchecked())
.collect();
let mut account_locks = self.account_locks.lock().unwrap();
debug!("bank unlock accounts");
Expand All @@ -639,7 +638,7 @@ impl Accounts {
pub fn store_cached(
&self,
slot: Slot,
txs: &[SanitizedTransaction],
txs: &[ExtendedSanitizedTransaction],
res: &[TransactionExecutionResult],
loaded: &mut [TransactionLoadResult],
durable_nonce: &DurableNonce,
Expand All @@ -666,14 +665,14 @@ impl Accounts {
#[allow(clippy::too_many_arguments)]
fn collect_accounts_to_store<'a>(
&self,
txs: &'a [SanitizedTransaction],
txs: &'a [ExtendedSanitizedTransaction],
execution_results: &'a [TransactionExecutionResult],
load_results: &'a mut [TransactionLoadResult],
durable_nonce: &DurableNonce,
lamports_per_signature: u64,
) -> (
Vec<(&'a Pubkey, &'a AccountSharedData)>,
Vec<Option<&'a SanitizedTransaction>>,
Vec<Option<&'a ExtendedSanitizedTransaction>>,
) {
let mut accounts = Vec::with_capacity(load_results.len());
let mut transactions = Vec::with_capacity(load_results.len());
Expand Down Expand Up @@ -701,7 +700,7 @@ impl Accounts {
}
};

let message = tx.message();
let message = tx.transaction.message();
let loaded_transaction = tx_load_result.as_mut().unwrap();
let mut fee_payer_index = None;
for (i, (address, account)) in (0..message.account_keys().len())
Expand Down
35 changes: 18 additions & 17 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use {
rent_collector::RentCollector,
saturating_add_assign,
timing::AtomicInterval,
transaction::SanitizedTransaction,
transaction::ExtendedSanitizedTransaction,
},
std::{
borrow::{Borrow, Cow},
Expand Down Expand Up @@ -6621,7 +6621,7 @@ impl AccountsDb {
&self,
slot: Slot,
accounts_and_meta_to_store: &impl StorableAccounts<'b, T>,
txn_iter: Box<dyn std::iter::Iterator<Item = &Option<&SanitizedTransaction>> + 'a>,
txn_iter: Box<dyn std::iter::Iterator<Item = &Option<&ExtendedSanitizedTransaction>> + 'a>,
mut write_version_producer: P,
) -> Vec<AccountInfo>
where
Expand All @@ -6639,7 +6639,7 @@ impl AccountsDb {
self.notify_account_at_accounts_update(
slot,
&account,
txn,
&txn.map(|txn| &txn.transaction),
accounts_and_meta_to_store.pubkey(i),
&mut write_version_producer,
);
Expand Down Expand Up @@ -6671,7 +6671,7 @@ impl AccountsDb {
hashes: Option<Vec<impl Borrow<AccountHash>>>,
mut write_version_producer: P,
store_to: &StoreTo,
transactions: Option<&[Option<&'a SanitizedTransaction>]>,
transactions: Option<&[Option<&'a ExtendedSanitizedTransaction>]>,
) -> Vec<AccountInfo> {
let mut calc_stored_meta_time = Measure::start("calc_stored_meta");
let slot = accounts.target_slot();
Expand All @@ -6686,14 +6686,15 @@ impl AccountsDb {

match store_to {
StoreTo::Cache => {
let txn_iter: Box<dyn std::iter::Iterator<Item = &Option<&SanitizedTransaction>>> =
match transactions {
Some(transactions) => {
assert_eq!(transactions.len(), accounts.len());
Box::new(transactions.iter())
}
None => Box::new(std::iter::repeat(&None).take(accounts.len())),
};
let txn_iter: Box<
dyn std::iter::Iterator<Item = &Option<&ExtendedSanitizedTransaction>>,
> = match transactions {
Some(transactions) => {
assert_eq!(transactions.len(), accounts.len());
Box::new(transactions.iter())
}
None => Box::new(std::iter::repeat(&None).take(accounts.len())),
};

self.write_accounts_to_cache(slot, accounts, txn_iter, write_version_producer)
}
Expand Down Expand Up @@ -8377,7 +8378,7 @@ impl AccountsDb {
pub fn store_cached<'a, T: ReadableAccount + Sync + ZeroLamport + 'a>(
&self,
accounts: impl StorableAccounts<'a, T>,
transactions: Option<&'a [Option<&'a SanitizedTransaction>]>,
transactions: Option<&'a [Option<&'a ExtendedSanitizedTransaction>]>,
) {
self.store(
accounts,
Expand All @@ -8394,7 +8395,7 @@ impl AccountsDb {
>(
&self,
accounts: impl StorableAccounts<'a, T>,
transactions: Option<&'a [Option<&'a SanitizedTransaction>]>,
transactions: Option<&'a [Option<&'a ExtendedSanitizedTransaction>]>,
) {
self.store(
accounts,
Expand Down Expand Up @@ -8422,7 +8423,7 @@ impl AccountsDb {
&self,
accounts: impl StorableAccounts<'a, T>,
store_to: &StoreTo,
transactions: Option<&'a [Option<&'a SanitizedTransaction>]>,
transactions: Option<&'a [Option<&'a ExtendedSanitizedTransaction>]>,
reclaim: StoreReclaims,
update_index_thread_selection: UpdateIndexThreadSelection,
) {
Expand Down Expand Up @@ -8613,7 +8614,7 @@ impl AccountsDb {
accounts: impl StorableAccounts<'a, T>,
hashes: Option<Vec<impl Borrow<AccountHash>>>,
store_to: &StoreTo,
transactions: Option<&'a [Option<&'a SanitizedTransaction>]>,
transactions: Option<&'a [Option<&'a ExtendedSanitizedTransaction>]>,
reclaim: StoreReclaims,
update_index_thread_selection: UpdateIndexThreadSelection,
) {
Expand Down Expand Up @@ -8668,7 +8669,7 @@ impl AccountsDb {
write_version_producer: Option<Box<dyn Iterator<Item = u64>>>,
store_to: &StoreTo,
reset_accounts: bool,
transactions: Option<&[Option<&SanitizedTransaction>]>,
transactions: Option<&[Option<&ExtendedSanitizedTransaction>]>,
reclaim: StoreReclaims,
update_index_thread_selection: UpdateIndexThreadSelection,
) -> StoreAccountsTiming {
Expand Down
10 changes: 8 additions & 2 deletions banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use {
message::{Message, SanitizedMessage},
pubkey::Pubkey,
signature::Signature,
transaction::{self, MessageHash, SanitizedTransaction, VersionedTransaction},
transaction::{
self, ExtendedSanitizedTransaction, MessageHash, SanitizedTransaction,
VersionedTransaction,
},
},
solana_send_transaction_service::{
send_transaction_service::{SendTransactionService, TransactionInfo},
Expand Down Expand Up @@ -194,7 +197,10 @@ fn simulate_transaction(
units_consumed,
return_data,
inner_instructions,
} = bank.simulate_transaction_unchecked(&sanitized_transaction, false);
} = bank.simulate_transaction_unchecked(
&ExtendedSanitizedTransaction::from(sanitized_transaction),
false,
);

let simulation_details = TransactionSimulationDetails {
logs,
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ solana-send-transaction-service = { workspace = true }
solana-streamer = { workspace = true }
solana-svm = { workspace = true }
solana-tpu-client = { workspace = true }
solana-transaction-metrics-tracker = { workspace = true }
solana-transaction-status = { workspace = true }
solana-turbine = { workspace = true }
solana-unified-scheduler-pool = { workspace = true }
Expand Down
Loading
Loading