remove type SnapshotStorage and uses (#29661)

This commit is contained in:
Jeff Washington (jwash) 2023-01-11 19:57:44 -06:00 committed by GitHub
parent 69c4db27c5
commit 14055fc3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 27 deletions

View File

@ -609,11 +609,10 @@ impl<'a> MultiThreadProgress<'a> {
/// An offset into the AccountsDb::storage vector /// An offset into the AccountsDb::storage vector
pub type AtomicAppendVecId = AtomicU32; pub type AtomicAppendVecId = AtomicU32;
pub type AppendVecId = u32; pub type AppendVecId = u32;
pub type SnapshotStorage = Vec<Arc<AccountStorageEntry>>;
pub type SnapshotStorageOne = Arc<AccountStorageEntry>; pub type SnapshotStorageOne = Arc<AccountStorageEntry>;
pub type SnapshotStorages = Vec<SnapshotStorage>; pub type SnapshotStorages = Vec<Vec<SnapshotStorageOne>>;
/// exactly 1 append vec per slot /// exactly 1 append vec per slot
pub type SnapshotStoragesOne = SnapshotStorage; pub type SnapshotStoragesOne = Vec<SnapshotStorageOne>;
// Each slot has a set of storage entries. // Each slot has a set of storage entries.
pub(crate) type SlotStores = Arc<RwLock<HashMap<AppendVecId, Arc<AccountStorageEntry>>>>; pub(crate) type SlotStores = Arc<RwLock<HashMap<AppendVecId, Arc<AccountStorageEntry>>>>;
@ -1143,7 +1142,7 @@ impl RecycleStores {
self.entries.iter() self.entries.iter()
} }
fn add_entries(&mut self, new_entries: SnapshotStorage) { fn add_entries(&mut self, new_entries: Vec<SnapshotStorageOne>) {
let now = Instant::now(); let now = Instant::now();
for new_entry in new_entries { for new_entry in new_entries {
self.total_bytes += new_entry.total_bytes(); self.total_bytes += new_entry.total_bytes();
@ -1151,7 +1150,7 @@ impl RecycleStores {
} }
} }
fn expire_old_entries(&mut self) -> SnapshotStorage { fn expire_old_entries(&mut self) -> Vec<SnapshotStorageOne> {
let mut expired = vec![]; let mut expired = vec![];
let now = Instant::now(); let now = Instant::now();
let mut expired_bytes = 0; let mut expired_bytes = 0;
@ -3917,7 +3916,7 @@ impl AccountsDb {
slot: Slot, slot: Slot,
add_dirty_stores: bool, add_dirty_stores: bool,
shrink_in_progress: Option<ShrinkInProgress>, shrink_in_progress: Option<ShrinkInProgress>,
) -> SnapshotStorage { ) -> Vec<SnapshotStorageOne> {
let mut dead_storages = Vec::default(); let mut dead_storages = Vec::default();
let mut not_retaining_store = |store: &Arc<AccountStorageEntry>| { let mut not_retaining_store = |store: &Arc<AccountStorageEntry>| {
@ -3945,7 +3944,7 @@ impl AccountsDb {
pub(crate) fn drop_or_recycle_stores( pub(crate) fn drop_or_recycle_stores(
&self, &self,
dead_storages: SnapshotStorage, dead_storages: Vec<SnapshotStorageOne>,
stats: &ShrinkStats, stats: &ShrinkStats,
) { ) {
let mut recycle_stores_write_elapsed = Measure::start("recycle_stores_write_time"); let mut recycle_stores_write_elapsed = Measure::start("recycle_stores_write_time");
@ -4168,7 +4167,7 @@ impl AccountsDb {
} }
#[cfg(test)] #[cfg(test)]
fn get_storages_for_slot(&self, slot: Slot) -> Option<SnapshotStorage> { fn get_storages_for_slot(&self, slot: Slot) -> Option<Vec<SnapshotStorageOne>> {
self.storage self.storage
.get_slot_storage_entry(slot) .get_slot_storage_entry(slot)
.map(|storage| vec![storage]) .map(|storage| vec![storage])
@ -13877,7 +13876,7 @@ pub mod tests {
} }
} }
fn slot_stores(db: &AccountsDb, slot: Slot) -> SnapshotStorage { fn slot_stores(db: &AccountsDb, slot: Slot) -> Vec<SnapshotStorageOne> {
db.get_storages_for_slot(slot).unwrap_or_default() db.get_storages_for_slot(slot).unwrap_or_default()
} }
@ -14233,8 +14232,7 @@ pub mod tests {
impl AccountsDb { impl AccountsDb {
fn get_and_assert_single_storage(&self, slot: Slot) -> Arc<AccountStorageEntry> { fn get_and_assert_single_storage(&self, slot: Slot) -> Arc<AccountStorageEntry> {
let mut storage_maps: SnapshotStorage = let mut storage_maps = self.get_storages_for_slot(slot).unwrap_or_default();
self.get_storages_for_slot(slot).unwrap_or_default();
assert_eq!(storage_maps.len(), 1); assert_eq!(storage_maps.len(), 1);
storage_maps.pop().unwrap() storage_maps.pop().unwrap()

View File

@ -3,7 +3,7 @@ use {
accounts::Accounts, accounts::Accounts,
accounts_db::{ accounts_db::{
AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AccountsDbConfig, AppendVecId, AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AccountsDbConfig, AppendVecId,
AtomicAppendVecId, BankHashInfo, IndexGenerationInfo, SnapshotStorage, AtomicAppendVecId, BankHashInfo, IndexGenerationInfo, SnapshotStorageOne,
}, },
accounts_hash::AccountsHash, accounts_hash::AccountsHash,
accounts_index::AccountSecondaryIndexes, accounts_index::AccountSecondaryIndexes,
@ -345,7 +345,7 @@ pub(crate) fn bank_to_stream<W>(
serde_style: SerdeStyle, serde_style: SerdeStyle,
stream: &mut BufWriter<W>, stream: &mut BufWriter<W>,
bank: &Bank, bank: &Bank,
snapshot_storages: &[SnapshotStorage], snapshot_storages: &[Vec<SnapshotStorageOne>],
) -> Result<(), Error> ) -> Result<(), Error>
where where
W: Write, W: Write,
@ -367,7 +367,7 @@ pub(crate) fn bank_to_stream_no_extra_fields<W>(
serde_style: SerdeStyle, serde_style: SerdeStyle,
stream: &mut BufWriter<W>, stream: &mut BufWriter<W>,
bank: &Bank, bank: &Bank,
snapshot_storages: &[SnapshotStorage], snapshot_storages: &[Vec<SnapshotStorageOne>],
) -> Result<(), Error> ) -> Result<(), Error>
where where
W: Write, W: Write,
@ -445,7 +445,7 @@ pub fn reserialize_bank_with_new_accounts_hash(
struct SerializableBankAndStorage<'a, C> { struct SerializableBankAndStorage<'a, C> {
bank: &'a Bank, bank: &'a Bank,
snapshot_storages: &'a [SnapshotStorage], snapshot_storages: &'a [Vec<SnapshotStorageOne>],
phantom: std::marker::PhantomData<C>, phantom: std::marker::PhantomData<C>,
} }
@ -461,7 +461,7 @@ impl<'a, C: TypeContext<'a>> Serialize for SerializableBankAndStorage<'a, C> {
#[cfg(test)] #[cfg(test)]
struct SerializableBankAndStorageNoExtra<'a, C> { struct SerializableBankAndStorageNoExtra<'a, C> {
bank: &'a Bank, bank: &'a Bank,
snapshot_storages: &'a [SnapshotStorage], snapshot_storages: &'a [Vec<SnapshotStorageOne>],
phantom: std::marker::PhantomData<C>, phantom: std::marker::PhantomData<C>,
} }
@ -494,7 +494,7 @@ impl<'a, C> From<SerializableBankAndStorageNoExtra<'a, C>> for SerializableBankA
struct SerializableAccountsDb<'a, C> { struct SerializableAccountsDb<'a, C> {
accounts_db: &'a AccountsDb, accounts_db: &'a AccountsDb,
slot: Slot, slot: Slot,
account_storage_entries: &'a [SnapshotStorage], account_storage_entries: &'a [Vec<SnapshotStorageOne>],
phantom: std::marker::PhantomData<C>, phantom: std::marker::PhantomData<C>,
} }

View File

@ -148,7 +148,7 @@ fn accountsdb_to_stream<W>(
stream: &mut W, stream: &mut W,
accounts_db: &AccountsDb, accounts_db: &AccountsDb,
slot: Slot, slot: Slot,
account_storage_entries: &[SnapshotStorage], account_storage_entries: &[Vec<SnapshotStorageOne>],
) -> Result<(), Error> ) -> Result<(), Error>
where where
W: Write, W: Write,

View File

@ -3,8 +3,7 @@
use { use {
crate::{ crate::{
accounts_db::{ accounts_db::{
AccountsDb, GetUniqueAccountsResult, PurgeStats, SnapshotStorage, SnapshotStorageOne, AccountsDb, GetUniqueAccountsResult, PurgeStats, SnapshotStorageOne, StoreReclaims,
StoreReclaims,
}, },
bank::Bank, bank::Bank,
builtins, static_ids, builtins, static_ids,
@ -274,7 +273,7 @@ impl<'a> SnapshotMinimizer<'a> {
fn process_snapshot_storages( fn process_snapshot_storages(
&self, &self,
minimized_slot_set: DashSet<Slot>, minimized_slot_set: DashSet<Slot>,
) -> (Vec<Slot>, SnapshotStorage) { ) -> (Vec<Slot>, Vec<SnapshotStorageOne>) {
let snapshot_storages = self let snapshot_storages = self
.accounts_db() .accounts_db()
.get_snapshot_storages(..=self.starting_slot, None) .get_snapshot_storages(..=self.starting_slot, None)
@ -300,7 +299,11 @@ impl<'a> SnapshotMinimizer<'a> {
} }
/// Creates new storage replacing `storages` that contains only accounts in `minimized_account_set`. /// Creates new storage replacing `storages` that contains only accounts in `minimized_account_set`.
fn filter_storage(&self, storage: &SnapshotStorageOne, dead_storages: &Mutex<SnapshotStorage>) { fn filter_storage(
&self,
storage: &SnapshotStorageOne,
dead_storages: &Mutex<Vec<SnapshotStorageOne>>,
) {
let slot = storage.slot(); let slot = storage.slot();
let GetUniqueAccountsResult { let GetUniqueAccountsResult {
stored_accounts, .. stored_accounts, ..

View File

@ -28,7 +28,7 @@ impl<'a> SortedStorages<'a> {
} }
} }
/// primary method of retrieving (Slot, SnapshotStorage) /// primary method of retrieving (Slot, SnapshotStorageOne)
pub fn iter_range<R>(&'a self, range: &R) -> SortedStoragesIter<'a> pub fn iter_range<R>(&'a self, range: &R) -> SortedStoragesIter<'a>
where where
R: RangeBounds<Slot>, R: RangeBounds<Slot>,
@ -60,9 +60,8 @@ impl<'a> SortedStorages<'a> {
self.storages.len() self.storages.len()
} }
// assumptions: // assumption:
// 1. each SnapshotStorage.!is_empty() // source.slot() is unique from all other items in 'source'
// 2. SnapshotStorage.first().unwrap().get_slot() is unique from all other SnapshotStorage items.
pub fn new(source: &'a [SnapshotStorageOne]) -> Self { pub fn new(source: &'a [SnapshotStorageOne]) -> Self {
let slots = source.iter().map(|storage| { let slots = source.iter().map(|storage| {
storage.slot() // this must be unique. Will be enforced in new_with_slots storage.slot() // this must be unique. Will be enforced in new_with_slots
@ -71,7 +70,7 @@ impl<'a> SortedStorages<'a> {
} }
/// create `SortedStorages` from 'source' iterator. /// create `SortedStorages` from 'source' iterator.
/// 'source' contains a SnapshotStorage and its associated slot /// 'source' contains a SnapshotStorageOne and its associated slot
/// 'source' does not have to be sorted in any way, but is assumed to not have duplicate slot #s /// 'source' does not have to be sorted in any way, but is assumed to not have duplicate slot #s
pub fn new_with_slots( pub fn new_with_slots(
source: impl Iterator<Item = (&'a SnapshotStorageOne, Slot)> + Clone, source: impl Iterator<Item = (&'a SnapshotStorageOne, Slot)> + Clone,