refactor, add GetUniqueAccountsResult (#26457)
This commit is contained in:
parent
8e64b5883e
commit
c9f1d01e79
|
@ -163,6 +163,12 @@ pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig
|
|||
|
||||
pub type BinnedHashData = Vec<Vec<CalculateHashIntermediate>>;
|
||||
|
||||
pub struct GetUniqueAccountsResult<'a> {
|
||||
pub stored_accounts: HashMap<Pubkey, FoundStoredAccount<'a>>,
|
||||
pub num_stores: usize,
|
||||
pub original_bytes: u64,
|
||||
}
|
||||
|
||||
pub struct AccountsAddRootTiming {
|
||||
pub index_us: u64,
|
||||
pub cache_us: u64,
|
||||
|
@ -3087,7 +3093,7 @@ impl AccountsDb {
|
|||
pub(crate) fn get_unique_accounts_from_storages<'a, I>(
|
||||
&'a self,
|
||||
stores: I,
|
||||
) -> (HashMap<Pubkey, FoundStoredAccount>, usize, u64)
|
||||
) -> GetUniqueAccountsResult<'a>
|
||||
where
|
||||
I: Iterator<Item = &'a Arc<AccountStorageEntry>>,
|
||||
{
|
||||
|
@ -3118,7 +3124,11 @@ impl AccountsDb {
|
|||
});
|
||||
num_stores += 1;
|
||||
}
|
||||
(stored_accounts, num_stores, original_bytes)
|
||||
GetUniqueAccountsResult {
|
||||
stored_accounts,
|
||||
num_stores,
|
||||
original_bytes,
|
||||
}
|
||||
}
|
||||
|
||||
fn do_shrink_slot_stores<'a, I>(&'a self, slot: Slot, stores: I) -> usize
|
||||
|
@ -3126,8 +3136,11 @@ impl AccountsDb {
|
|||
I: Iterator<Item = &'a Arc<AccountStorageEntry>>,
|
||||
{
|
||||
debug!("do_shrink_slot_stores: slot: {}", slot);
|
||||
let (stored_accounts, num_stores, original_bytes) =
|
||||
self.get_unique_accounts_from_storages(stores);
|
||||
let GetUniqueAccountsResult {
|
||||
stored_accounts,
|
||||
num_stores,
|
||||
original_bytes,
|
||||
} = self.get_unique_accounts_from_storages(stores);
|
||||
|
||||
// sort by pubkey to keep account index lookups close
|
||||
let mut stored_accounts = stored_accounts.into_iter().collect::<Vec<_>>();
|
||||
|
@ -3683,8 +3696,11 @@ impl AccountsDb {
|
|||
}
|
||||
|
||||
// this code is copied from shrink. I would like to combine it into a helper function, but the borrow checker has defeated my efforts so far.
|
||||
let (stored_accounts, _num_stores, original_bytes) =
|
||||
self.get_unique_accounts_from_storages(old_storages.iter());
|
||||
let GetUniqueAccountsResult {
|
||||
stored_accounts,
|
||||
num_stores: _num_stores,
|
||||
original_bytes,
|
||||
} = self.get_unique_accounts_from_storages(old_storages.iter());
|
||||
|
||||
// sort by pubkey to keep account index lookups close
|
||||
let mut stored_accounts = stored_accounts.into_iter().collect::<Vec<_>>();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use {
|
||||
crate::{
|
||||
accounts_db::{AccountStorageEntry, AccountsDb, PurgeStats},
|
||||
accounts_db::{AccountStorageEntry, AccountsDb, GetUniqueAccountsResult, PurgeStats},
|
||||
bank::Bank,
|
||||
builtins, static_ids,
|
||||
},
|
||||
|
@ -302,7 +302,9 @@ impl<'a> SnapshotMinimizer<'a> {
|
|||
dead_storages: &Mutex<Vec<Arc<AccountStorageEntry>>>,
|
||||
) {
|
||||
let slot = storages.first().unwrap().slot();
|
||||
let (stored_accounts, _, _) = self
|
||||
let GetUniqueAccountsResult {
|
||||
stored_accounts, ..
|
||||
} = self
|
||||
.accounts_db()
|
||||
.get_unique_accounts_from_storages(storages.iter());
|
||||
let mut stored_accounts = stored_accounts.into_iter().collect::<Vec<_>>();
|
||||
|
|
Loading…
Reference in New Issue