Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_storages_for_slot uses get_slot_storage_entry #29498

Merged
merged 1 commit into from
Jan 4, 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
9 changes: 0 additions & 9 deletions runtime/src/account_storage.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Manage the map of slot -> append vecs

#[cfg(test)]
use crate::accounts_db::SnapshotStorage;
use {
crate::accounts_db::{AccountStorageEntry, AppendVecId, SlotStores},
dashmap::DashMap,
Expand Down Expand Up @@ -44,13 +42,6 @@ impl AccountStorage {
})
}

/// return all append vecs for 'slot' if any exist
#[cfg(test)]
pub(crate) fn get_slot_storage_entries(&self, slot: Slot) -> Option<SnapshotStorage> {
self.get_slot_stores(slot)
.map(|res| res.read().unwrap().values().cloned().collect())
}

pub(crate) fn all_slots(&self) -> Vec<Slot> {
self.map.iter().map(|iter_item| *iter_item.key()).collect()
}
Expand Down
33 changes: 10 additions & 23 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4266,7 +4266,9 @@ impl AccountsDb {

#[cfg(test)]
fn get_storages_for_slot(&self, slot: Slot) -> Option<SnapshotStorage> {
self.storage.get_slot_storage_entries(slot)
self.storage
.get_slot_storage_entry(slot)
.map(|storage| vec![storage])
}

/// 'accounts' that exist in the current slot we are combining into a different ancient slot
Expand Down Expand Up @@ -14216,9 +14218,7 @@ pub mod tests {
}

fn slot_stores(db: &AccountsDb, slot: Slot) -> SnapshotStorage {
db.storage
.get_slot_storage_entries(slot)
.unwrap_or_default()
db.get_storages_for_slot(slot).unwrap_or_default()
}

#[test]
Expand Down Expand Up @@ -14573,10 +14573,8 @@ pub mod tests {

impl AccountsDb {
fn get_and_assert_single_storage(&self, slot: Slot) -> Arc<AccountStorageEntry> {
let mut storage_maps: SnapshotStorage = self
.storage
.get_slot_storage_entries(slot)
.unwrap_or_default();
let mut storage_maps: SnapshotStorage =
self.get_storages_for_slot(slot).unwrap_or_default();

assert_eq!(storage_maps.len(), 1);
storage_maps.pop().unwrap()
Expand Down Expand Up @@ -15856,10 +15854,7 @@ pub mod tests {
accounts.store_for_tests(slot0, &[(&shared_key, &account)]);
accounts.add_root_and_flush_write_cache(slot0);

let storage_maps = accounts
.storage
.get_slot_storage_entries(slot0)
.unwrap_or_default();
let storage_maps = accounts.get_storages_for_slot(slot0).unwrap_or_default();
let storage_info = StorageSizeAndCountMap::default();
let accounts_map = accounts.process_storage_slot(&storage_maps[..]);
AccountsDb::update_storage_info(&storage_info, &accounts_map, &Mutex::default());
Expand Down Expand Up @@ -15908,10 +15903,7 @@ pub mod tests {
accounts.store_for_tests(slot0, &[(&keys[1], &account_big)]);
accounts.add_root_and_flush_write_cache(slot0);

let storage_maps = accounts
.storage
.get_slot_storage_entries(slot0)
.unwrap_or_default();
let storage_maps = accounts.get_storages_for_slot(slot0).unwrap_or_default();
let storage_info = StorageSizeAndCountMap::default();
let accounts_map = accounts.process_storage_slot(&storage_maps[..]);
AccountsDb::update_storage_info(&storage_info, &accounts_map, &Mutex::default());
Expand Down Expand Up @@ -16013,7 +16005,7 @@ pub mod tests {

/// asserts that not only are there 0 append vecs, but there is not even an entry in the storage map for 'slot'
fn assert_no_storages_at_slot(db: &AccountsDb, slot: Slot) {
assert!(db.storage.get_slot_storage_entries(slot).is_none());
assert!(db.get_storages_for_slot(slot).is_none());
}

/// Test to make sure `clean_accounts()` works properly with the `last_full_snapshot_slot`
Expand Down Expand Up @@ -17401,12 +17393,7 @@ pub mod tests {
let max_slot_inclusive = ancient_slot + (num_normal_slots as Slot);
let initial_accounts = get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1));

let ancient = db
.get_storages_for_slot(ancient_slot)
.unwrap()
.first()
.unwrap()
.clone();
let ancient = db.storage.get_slot_storage_entry(ancient_slot).unwrap();
let initial_len = ancient.alive_bytes();
// set size of ancient to be 'full'
adjust_append_vec_len_for_tests(&ancient, ancient.accounts.capacity() as usize);
Expand Down