Skip to content

Commit

Permalink
get_snapshot_storages removes call to AccountStorage.get (solana-labs…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored and gnapoli23 committed Jan 10, 2023
1 parent 71431df commit c778bdd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
10 changes: 1 addition & 9 deletions runtime/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
dashmap::DashMap,
solana_sdk::clock::Slot,
std::{
collections::{hash_map::RandomState, HashMap},
collections::HashMap,
sync::{Arc, RwLock},
},
};
Expand Down Expand Up @@ -65,14 +65,6 @@ impl AccountStorage {
self.map.iter()
}

pub(crate) fn get(
&self,
slot: &Slot,
) -> Option<dashmap::mapref::one::Ref<'_, Slot, SlotStores, RandomState>> {
self.map.get(slot)
}

/// insert 'store' into 'map' at 'slot'
pub(crate) fn insert(&self, slot: Slot, store: Arc<AccountStorageEntry>) {
let slot_storages: SlotStores = self.get_slot_stores(slot).unwrap_or_else(||
// DashMap entry.or_insert() returns a RefMut, essentially a write lock,
Expand Down
39 changes: 19 additions & 20 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8533,8 +8533,12 @@ impl AccountsDb {
let slots = self
.storage
.iter()
.map(|k| *k.key() as Slot)
.filter(|slot| requested_slots.contains(slot))
.filter_map(|entry| {
let slot = *entry.key() as Slot;
requested_slots
.contains(&slot)
.then_some((slot, Arc::clone(entry.value())))
})
.collect::<Vec<_>>();
m.stop();
let mut m2 = Measure::start("filter");
Expand All @@ -8546,29 +8550,24 @@ impl AccountsDb {
.map(|slots| {
slots
.iter()
.filter_map(|slot| {
.filter_map(|(slot, storages)| {
if self.accounts_index.is_alive_root(*slot)
|| ancestors
.map(|ancestors| ancestors.contains_key(slot))
.unwrap_or_default()
{
self.storage.get(slot).map_or_else(
|| None,
|item| {
let storages = item
.read()
.unwrap()
.values()
.filter(|x| x.has_accounts())
.cloned()
.collect::<Vec<_>>();
if !storages.is_empty() {
Some((storages, *slot))
} else {
None
}
},
)
let storages = storages
.read()
.unwrap()
.values()
.filter(|x| x.has_accounts())
.cloned()
.collect::<Vec<_>>();
if !storages.is_empty() {
Some((storages, *slot))
} else {
None
}
} else {
None
}
Expand Down

0 comments on commit c778bdd

Please sign in to comment.