Skip to content

Commit

Permalink
Bank::check_status_cache: allocate outside read lock (#3394)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored Nov 1, 2024
1 parent 04ca408 commit cec047d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions runtime/src/bank/check_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ impl Bank {
lock_results: Vec<TransactionCheckResult>,
error_counters: &mut TransactionErrorMetrics,
) -> Vec<TransactionCheckResult> {
// Do allocation before acquiring the lock on the status cache.
let mut check_results = Vec::with_capacity(sanitized_txs.len());
let rcache = self.status_cache.read().unwrap();
sanitized_txs
.iter()
.zip(lock_results)
.map(|(sanitized_tx, lock_result)| {

check_results.extend(sanitized_txs.iter().zip(lock_results).map(
|(sanitized_tx, lock_result)| {
let sanitized_tx = sanitized_tx.borrow();
if lock_result.is_ok()
&& self.is_transaction_already_processed(sanitized_tx, &rcache)
Expand All @@ -202,8 +203,9 @@ impl Bank {
}

lock_result
})
.collect()
},
));
check_results
}

fn is_transaction_already_processed(
Expand Down

0 comments on commit cec047d

Please sign in to comment.