diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 6b316968171341..a6128001f0b74b 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -265,7 +265,7 @@ pub enum BufferedPacketsDecision { pub struct CommittedTransactionBatch { pub transactions: Vec, - pub statuses: Vec, + pub execution_results: Vec, } impl BankingStage { @@ -751,9 +751,9 @@ impl BankingStage { } // */ - for (txs, execution_results) in cost_update_receiver.try_iter() { - for ((result, _), tx) in execution_results.iter().zip(txs.iter()) { - if result.0.is_ok() { + for batch in cost_update_receiver.try_iter() { + for ((result, _), tx) in batch.execution_results.iter().zip(batch.transactions.iter()) { + if result.is_ok() { cost_model .read() .unwrap() @@ -1018,10 +1018,13 @@ impl BankingStage { } // track committed transactions' cost - let transactions = batch.transaction_iter().cloned().collect(); - cost_tracker_update_sender.send(CommittedTransactionBatch {transactions, tx_results.execution_results} - ).expect("send committed transactions to update cost model"); - + let transactions = batch.transactions_iter().cloned().collect(); + let execution_results = results.to_vec(); + cost_tracker_update_sender.send( + CommittedTransactionBatch { + transactions, + execution_results, + } ).expect("send committed transactions to update cost model"); } commit_time.stop(); @@ -1113,7 +1116,7 @@ impl BankingStage { chunk_start, transaction_status_sender.clone(), gossip_vote_sender, - cost_tracker_update_sender, + cost_tracker_update_sender.clone(), ); trace!("process_transactions result: {:?}", result); @@ -1361,32 +1364,20 @@ impl BankingStage { unprocessed_tx_count ); - // applying cost of processed transactions to shared cost_tracker let mut cost_tracking_time = Measure::start("cost_tracking_time"); - /* TODO TAO - replaced - let mut tx_cost = TransactionCost::new_with_capacity(MAX_WRITABLE_ACCOUNTS); - // */ + /* TODO TAO - doing in batch fashino right after committing, to + * save 1) nested for-loop, 2) individual transaction cloning + // applying cost of processed transactions to shared cost_tracker { - //let cost_model_readonly = cost_model.read().unwrap(); - //let mut cost_tracker_mutable = cost_tracker.write().unwrap(); transactions.iter().enumerate().for_each(|(index, tx)| { if !unprocessed_tx_indexes.iter().any(|&i| i == index) { cost_update_sender .send(tx.transaction().clone()) .expect("send transaction to cost_model"); - /* TODO TAO - replaced - cost_model - .read() - .unwrap() - .calculate_cost_no_alloc(tx.transaction(), &mut tx_cost); - cost_tracker.write().unwrap().add_transaction( - &tx_cost.writable_accounts, - &(tx_cost.account_access_cost + tx_cost.execution_cost), - ); - // */ } }); } + // */ cost_tracking_time.stop(); let mut filter_pending_packets_time = Measure::start("filter_pending_packets_time");