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

V0.12 #3477

Merged
merged 2 commits into from
Mar 25, 2019
Merged

V0.12 #3477

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 37 additions & 15 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,22 @@ impl BankingStage {
Ok(())
}

pub fn process_and_record_transactions(
fn process_and_record_transactions_locked(
bank: &Bank,
txs: &[Transaction],
poh: &Arc<Mutex<PohRecorder>>,
lock_results: &[bank::Result<()>],
) -> Result<()> {
let now = Instant::now();
// Once accounts are locked, other threads cannot encode transactions that will modify the
// same account state
let lock_results = bank.lock_accounts(txs);
let lock_time = now.elapsed();

let now = Instant::now();
// Use a shorter maximum age when adding transactions into the pipeline. This will reduce
// the likelihood of any single thread getting starved and processing old ids.
// TODO: Banking stage threads should be prioritized to complete faster then this queue
// expires.
let (loaded_accounts, results) =
bank.load_and_execute_transactions(txs, lock_results, MAX_RECENT_BLOCKHASHES / 2);
let (loaded_accounts, results) = bank.load_and_execute_transactions(
txs,
lock_results.to_vec(),
MAX_RECENT_BLOCKHASHES / 2,
);
let load_execute_time = now.elapsed();

let record_time = {
Expand All @@ -255,21 +253,45 @@ impl BankingStage {
now.elapsed()
};

debug!(
"bank: {} load_execute: {}us record: {}us commit: {}us txs_len: {}",
bank.slot(),
duration_as_us(&load_execute_time),
duration_as_us(&record_time),
duration_as_us(&commit_time),
txs.len(),
);

Ok(())
}

pub fn process_and_record_transactions(
bank: &Bank,
txs: &[Transaction],
poh: &Arc<Mutex<PohRecorder>>,
) -> Result<()> {
let now = Instant::now();
// Once accounts are locked, other threads cannot encode transactions that will modify the
// same account state
let lock_results = bank.lock_accounts(txs);
let lock_time = now.elapsed();

let results = Self::process_and_record_transactions_locked(bank, txs, poh, &lock_results);

let now = Instant::now();
// Once the accounts are new transactions can enter the pipeline to process them
bank.unlock_accounts(&txs, &results);
bank.unlock_accounts(&txs, &lock_results);
let unlock_time = now.elapsed();

debug!(
"bank: {} lock: {}us load_execute: {}us record: {}us commit: {}us unlock: {}us txs_len: {}",
"bank: {} lock: {}us unlock: {}us txs_len: {}",
bank.slot(),
duration_as_us(&lock_time),
duration_as_us(&load_execute_time),
duration_as_us(&record_time),
duration_as_us(&commit_time),
duration_as_us(&unlock_time),
txs.len(),
);
Ok(())

results
}

/// Sends transactions to the bank.
Expand Down
4 changes: 0 additions & 4 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ impl AccountsDB {
.map_or(0, |fork_info| fork_info.transaction_count)
}

#[allow(dead_code)]
fn remove_parents(&self, fork: Fork) -> Vec<Fork> {
let mut info = self.fork_infos.write().unwrap();
let fork_info = info.get_mut(&fork).unwrap();
Expand All @@ -744,7 +743,6 @@ impl AccountsDB {
.is_empty()
}

#[allow(dead_code)]
fn get_merged_account_map(
&self,
fork: Fork,
Expand All @@ -765,7 +763,6 @@ impl AccountsDB {
}

/// make fork a root, i.e. forget its heritage
#[allow(dead_code)]
fn squash(&self, fork: Fork) {
let parents = self.remove_parents(fork);

Expand Down Expand Up @@ -994,7 +991,6 @@ impl Accounts {

/// accounts starts with an empty data structure for every child/fork
/// this function squashes all the parents into this instance
#[allow(dead_code)]
pub fn squash(&self, fork: Fork) {
assert!(!self.account_locks.lock().unwrap().contains_key(&fork));
self.accounts_db.squash(fork);
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl Bank {
let parents = self.parents();
*self.parent.write().unwrap() = None;

// self.accounts().squash(self.accounts_id);
self.accounts().squash(self.accounts_id);

let parent_caches: Vec<_> = parents
.iter()
Expand Down