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

Commit

Permalink
wip - testing if batch helps stats
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Jun 28, 2021
1 parent a8321d5 commit a7a14a3
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ pub enum BufferedPacketsDecision {

pub struct CommittedTransactionBatch {
pub transactions: Vec<Transaction>,
pub statuses: Vec<TransactionExecutionResult>,
pub execution_results: Vec<TransactionExecutionResult>,
}

impl BankingStage {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a7a14a3

Please sign in to comment.