Skip to content

Commit

Permalink
blockstore: Remove unnecessary function and threadpool (anza-xyz#122)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
steviez authored Mar 7, 2024
1 parent c6bd388 commit 26692e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 36 deletions.
36 changes: 1 addition & 35 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<Entry> {
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<Vec<Entry>> = 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<HashMap<Slot, Vec<Slot>>> {
Expand Down
3 changes: 2 additions & 1 deletion ledger/src/blockstore/blockstore_purge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 26692e6

Please sign in to comment.