Push recyclers down the stack

This commit is contained in:
Michael Vines
2022-03-05 14:16:39 +01:00
parent fc2d1a61f3
commit 07d5ee062d
2 changed files with 41 additions and 32 deletions

View File

@ -8,7 +8,6 @@ use {
leader_schedule_cache::LeaderScheduleCache, leader_schedule_cache::LeaderScheduleCache,
}, },
log::*, log::*,
solana_entry::entry::VerifyRecyclers,
solana_runtime::{ solana_runtime::{
accounts_update_notifier_interface::AccountsUpdateNotifier, accounts_update_notifier_interface::AccountsUpdateNotifier,
bank_forks::BankForks, bank_forks::BankForks,
@ -194,7 +193,6 @@ fn load_from_snapshot(
blockstore, blockstore,
bank_forks, bank_forks,
&process_options, &process_options,
&VerifyRecyclers::default(),
transaction_status_sender, transaction_status_sender,
cache_block_meta_sender, cache_block_meta_sender,
Some(snapshot_config), Some(snapshot_config),

View File

@ -576,15 +576,34 @@ pub fn process_blockstore(
accounts_package_sender: AccountsPackageSender, accounts_package_sender: AccountsPackageSender,
accounts_update_notifier: Option<AccountsUpdateNotifier>, accounts_update_notifier: Option<AccountsUpdateNotifier>,
) -> BlockstoreProcessorResult { ) -> BlockstoreProcessorResult {
if let Some(num_threads) = opts.override_num_threads { let bank_forks = process_blockstore_for_bank_0(
PAR_THREAD_POOL.with(|pool| { genesis_config,
*pool.borrow_mut() = rayon::ThreadPoolBuilder::new() blockstore,
.num_threads(num_threads) account_paths,
.build() &opts,
.unwrap() cache_block_meta_sender,
}); accounts_update_notifier,
} );
do_process_blockstore_from_root(
blockstore,
bank_forks,
&opts,
None,
cache_block_meta_sender,
snapshot_config,
accounts_package_sender,
None,
)
}
fn process_blockstore_for_bank_0(
genesis_config: &GenesisConfig,
blockstore: &Blockstore,
account_paths: Vec<PathBuf>,
opts: &ProcessOptions,
cache_block_meta_sender: Option<&CacheBlockMetaSender>,
accounts_update_notifier: Option<AccountsUpdateNotifier>,
) -> BankForks {
// Setup bank for slot 0 // Setup bank for slot 0
let bank0 = Bank::new_with_paths( let bank0 = Bank::new_with_paths(
genesis_config, genesis_config,
@ -601,25 +620,14 @@ pub fn process_blockstore(
let bank_forks = BankForks::new(bank0); let bank_forks = BankForks::new(bank0);
info!("processing ledger for slot 0..."); info!("processing ledger for slot 0...");
let recyclers = VerifyRecyclers::default();
process_bank_0( process_bank_0(
&bank_forks.root_bank(), &bank_forks.root_bank(),
blockstore, blockstore,
&opts, opts,
&recyclers, &VerifyRecyclers::default(),
cache_block_meta_sender, cache_block_meta_sender,
); );
do_process_blockstore_from_root( bank_forks
blockstore,
bank_forks,
&opts,
&recyclers,
None,
cache_block_meta_sender,
snapshot_config,
accounts_package_sender,
None,
)
} }
/// Process blockstore from a known root bank /// Process blockstore from a known root bank
@ -628,7 +636,6 @@ pub(crate) fn process_blockstore_from_root(
blockstore: &Blockstore, blockstore: &Blockstore,
bank_forks: BankForks, bank_forks: BankForks,
opts: &ProcessOptions, opts: &ProcessOptions,
recyclers: &VerifyRecyclers,
transaction_status_sender: Option<&TransactionStatusSender>, transaction_status_sender: Option<&TransactionStatusSender>,
cache_block_meta_sender: Option<&CacheBlockMetaSender>, cache_block_meta_sender: Option<&CacheBlockMetaSender>,
snapshot_config: Option<&SnapshotConfig>, snapshot_config: Option<&SnapshotConfig>,
@ -639,7 +646,6 @@ pub(crate) fn process_blockstore_from_root(
blockstore, blockstore,
bank_forks, bank_forks,
opts, opts,
recyclers,
transaction_status_sender, transaction_status_sender,
cache_block_meta_sender, cache_block_meta_sender,
snapshot_config, snapshot_config,
@ -653,13 +659,21 @@ fn do_process_blockstore_from_root(
blockstore: &Blockstore, blockstore: &Blockstore,
mut bank_forks: BankForks, mut bank_forks: BankForks,
opts: &ProcessOptions, opts: &ProcessOptions,
recyclers: &VerifyRecyclers,
transaction_status_sender: Option<&TransactionStatusSender>, transaction_status_sender: Option<&TransactionStatusSender>,
cache_block_meta_sender: Option<&CacheBlockMetaSender>, cache_block_meta_sender: Option<&CacheBlockMetaSender>,
snapshot_config: Option<&SnapshotConfig>, snapshot_config: Option<&SnapshotConfig>,
accounts_package_sender: AccountsPackageSender, accounts_package_sender: AccountsPackageSender,
mut last_full_snapshot_slot: Option<Slot>, mut last_full_snapshot_slot: Option<Slot>,
) -> BlockstoreProcessorResult { ) -> BlockstoreProcessorResult {
if let Some(num_threads) = opts.override_num_threads {
PAR_THREAD_POOL.with(|pool| {
*pool.borrow_mut() = rayon::ThreadPoolBuilder::new()
.num_threads(num_threads)
.build()
.unwrap()
});
}
// Starting slot must be a root, and thus has no parents // Starting slot must be a root, and thus has no parents
assert_eq!(bank_forks.banks().len(), 1); assert_eq!(bank_forks.banks().len(), 1);
let bank = bank_forks.root_bank(); let bank = bank_forks.root_bank();
@ -720,7 +734,6 @@ fn do_process_blockstore_from_root(
blockstore, blockstore,
&leader_schedule_cache, &leader_schedule_cache,
opts, opts,
recyclers,
transaction_status_sender, transaction_status_sender,
cache_block_meta_sender, cache_block_meta_sender,
snapshot_config, snapshot_config,
@ -1142,7 +1155,6 @@ fn load_frozen_forks(
blockstore: &Blockstore, blockstore: &Blockstore,
leader_schedule_cache: &LeaderScheduleCache, leader_schedule_cache: &LeaderScheduleCache,
opts: &ProcessOptions, opts: &ProcessOptions,
recyclers: &VerifyRecyclers,
transaction_status_sender: Option<&TransactionStatusSender>, transaction_status_sender: Option<&TransactionStatusSender>,
cache_block_meta_sender: Option<&CacheBlockMetaSender>, cache_block_meta_sender: Option<&CacheBlockMetaSender>,
snapshot_config: Option<&SnapshotConfig>, snapshot_config: Option<&SnapshotConfig>,
@ -1150,6 +1162,7 @@ fn load_frozen_forks(
timing: &mut ExecuteTimings, timing: &mut ExecuteTimings,
last_full_snapshot_slot: &mut Option<Slot>, last_full_snapshot_slot: &mut Option<Slot>,
) -> result::Result<(), BlockstoreProcessorError> { ) -> result::Result<(), BlockstoreProcessorError> {
let recyclers = VerifyRecyclers::default();
let mut all_banks = HashMap::new(); let mut all_banks = HashMap::new();
let mut last_status_report = Instant::now(); let mut last_status_report = Instant::now();
let mut last_free = Instant::now(); let mut last_free = Instant::now();
@ -1201,7 +1214,7 @@ fn load_frozen_forks(
blockstore, blockstore,
&bank, &bank,
opts, opts,
recyclers, &recyclers,
&mut progress, &mut progress,
transaction_status_sender, transaction_status_sender,
cache_block_meta_sender, cache_block_meta_sender,
@ -3197,7 +3210,6 @@ pub mod tests {
&blockstore, &blockstore,
bank_forks, bank_forks,
&opts, &opts,
&recyclers,
None, None,
None, None,
None, None,
@ -3306,7 +3318,6 @@ pub mod tests {
&blockstore, &blockstore,
bank_forks, bank_forks,
&opts, &opts,
&recyclers,
None, None,
None, None,
Some(&snapshot_config), Some(&snapshot_config),