From 26692e666454d340a6691e2483194934e6a8ddfc Mon Sep 17 00:00:00 2001 From: steviez Date: Thu, 7 Mar 2024 16:06:31 -0600 Subject: [PATCH] blockstore: Remove unnecessary function and threadpool (#122) In a previous change, we removed the threadpool used to fetch entries in parallel in favor of combining all fetches into a single rocksdb multi_get() call. This change does the same thing, except for a threadpool that was used to fetch entries when we needed them to purge the transaction status and address signatures columns. --- ledger/src/blockstore.rs | 36 +---------------------- ledger/src/blockstore/blockstore_purge.rs | 3 +- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index f8c8330843dfce..f15976abdb241b 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -31,10 +31,7 @@ use { itertools::Itertools, log::*, rand::Rng, - rayon::{ - iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}, - ThreadPool, - }, + rayon::iter::{IntoParallelIterator, ParallelIterator}, rocksdb::{DBRawIterator, LiveFile}, solana_accounts_db::hardened_unpack::{ unpack_genesis_archive, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, @@ -94,16 +91,6 @@ pub use { rocksdb::properties as RocksProperties, }; -// get_max_thread_count to match number of threads in the old code. -// see: https://github.com/solana-labs/solana/pull/24853 -lazy_static! { - static ref PAR_THREAD_POOL_ALL_CPUS: ThreadPool = rayon::ThreadPoolBuilder::new() - .num_threads(num_cpus::get()) - .thread_name(|i| format!("solBstoreAll{i:02}")) - .build() - .unwrap(); -} - pub const MAX_REPLAY_WAKE_UP_SIGNALS: usize = 1; pub const MAX_COMPLETED_SLOTS_IN_CHANNEL: usize = 100_000; @@ -3283,27 +3270,6 @@ impl Blockstore { self.get_slot_entries_in_block(slot, vec![(start_index, end_index)], slot_meta) } - fn get_any_valid_slot_entries(&self, slot: Slot, start_index: u64) -> Vec { - let (completed_ranges, slot_meta) = self - .get_completed_ranges(slot, start_index) - .unwrap_or_default(); - if completed_ranges.is_empty() { - return vec![]; - } - let slot_meta = slot_meta.unwrap(); - - let entries: Vec> = PAR_THREAD_POOL_ALL_CPUS.install(|| { - completed_ranges - .par_iter() - .map(|(start_index, end_index)| { - self.get_entries_in_data_block(slot, *start_index, *end_index, Some(&slot_meta)) - .unwrap_or_default() - }) - .collect() - }); - entries.into_iter().flatten().collect() - } - /// Returns a mapping from each elements of `slots` to a list of the /// element's children slots. pub fn get_slots_since(&self, slots: &[Slot]) -> Result>> { diff --git a/ledger/src/blockstore/blockstore_purge.rs b/ledger/src/blockstore/blockstore_purge.rs index d8b4c7424cd8c1..d442732303fa2a 100644 --- a/ledger/src/blockstore/blockstore_purge.rs +++ b/ledger/src/blockstore/blockstore_purge.rs @@ -455,7 +455,8 @@ impl Blockstore { for slot in from_slot..=to_slot { let primary_indexes = slot_indexes(slot); - let slot_entries = self.get_any_valid_slot_entries(slot, 0); + let (slot_entries, _, _) = + self.get_slot_entries_with_shred_info(slot, 0, true /* allow_dead_slots */)?; let transactions = slot_entries .into_iter() .flat_map(|entry| entry.transactions);