From 8f8f87b93137fd0259db61902eaa41aaf094395d Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Wed, 3 Jul 2024 10:48:40 -0500 Subject: [PATCH] PrioGraphScheduler::try_schedule_transaction remove TransactionAccountLocks allocation (#1760) --- .../prio_graph_scheduler.rs | 16 +++++++++++++--- sdk/program/src/message/account_keys.rs | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs b/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs index 045d2cca1d8dba..59ce92173ed26e 100644 --- a/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs +++ b/core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs @@ -556,10 +556,20 @@ fn try_schedule_transaction( } // Schedule the transaction if it can be. - let transaction_locks = transaction.get_account_locks_unchecked(); + let message = transaction.message(); + let account_keys = message.account_keys(); + let write_account_locks = account_keys + .iter() + .enumerate() + .filter_map(|(index, key)| message.is_writable(index).then_some(key)); + let read_account_locks = account_keys + .iter() + .enumerate() + .filter_map(|(index, key)| (!message.is_writable(index)).then_some(key)); + let Some(thread_id) = account_locks.try_lock_accounts( - transaction_locks.writable.into_iter(), - transaction_locks.readonly.into_iter(), + write_account_locks, + read_account_locks, ThreadSet::any(num_threads), thread_selector, ) else { diff --git a/sdk/program/src/message/account_keys.rs b/sdk/program/src/message/account_keys.rs index 6f80c3c68e6186..e7bb569d03643b 100644 --- a/sdk/program/src/message/account_keys.rs +++ b/sdk/program/src/message/account_keys.rs @@ -33,7 +33,7 @@ impl<'a> AccountKeys<'a> { /// Returns an iterator of account key segments. The ordering of segments /// affects how account indexes from compiled instructions are resolved and /// so should not be changed. - fn key_segment_iter(&self) -> impl Iterator { + fn key_segment_iter(&self) -> impl Iterator + Clone { if let Some(dynamic_keys) = self.dynamic_keys { [ self.static_keys, @@ -77,7 +77,7 @@ impl<'a> AccountKeys<'a> { } /// Iterator for the addresses of the loaded accounts for a message - pub fn iter(&self) -> impl Iterator { + pub fn iter(&self) -> impl Iterator + Clone { self.key_segment_iter().flatten() }