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

get_snapshot_storages removes call to AccountStorage.get #29466

Merged
merged 1 commit into from
Jan 3, 2023
Merged
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
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 @@ -63,14 +63,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 @@ -8532,8 +8532,12 @@ impl AccountsDb {
let slots = self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider renaming this as it's not just the slots anymore, and includes slots & storages.

.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())))
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, now it's clear why it was that way in the previous PR 😄

.collect::<Vec<_>>();
m.stop();
let mut m2 = Measure::start("filter");
Expand All @@ -8545,29 +8549,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