combine sort into get_unique_accounts_from_storages (#28450)
This commit is contained in:
parent
b583ec79e1
commit
d52e28ac22
|
@ -225,7 +225,7 @@ 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 stored_accounts: Vec<(Pubkey, FoundStoredAccount<'a>)>,
|
||||
pub original_bytes: u64,
|
||||
store_ids: Vec<AppendVecId>,
|
||||
}
|
||||
|
@ -3608,6 +3608,11 @@ impl AccountsDb {
|
|||
store.append_vec_id()
|
||||
})
|
||||
.collect();
|
||||
|
||||
// sort by pubkey to keep account index lookups close
|
||||
let mut stored_accounts = stored_accounts.into_iter().collect::<Vec<_>>();
|
||||
stored_accounts.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
GetUniqueAccountsResult {
|
||||
stored_accounts,
|
||||
original_bytes,
|
||||
|
@ -3626,10 +3631,6 @@ impl AccountsDb {
|
|||
store_ids,
|
||||
} = 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<_>>();
|
||||
stored_accounts.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
let mut index_read_elapsed = Measure::start("index_read_elapsed");
|
||||
let alive_total_collect = AtomicUsize::new(0);
|
||||
|
||||
|
@ -4280,13 +4281,6 @@ impl AccountsDb {
|
|||
store_ids: _,
|
||||
} = self.get_unique_accounts_from_storages(old_storages.iter());
|
||||
|
||||
// sort by pubkey to keep account index lookups close
|
||||
let stored_accounts = {
|
||||
let mut stored_accounts = stored_accounts.into_iter().collect::<Vec<_>>();
|
||||
stored_accounts.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
||||
stored_accounts
|
||||
};
|
||||
|
||||
let mut index_read_elapsed = Measure::start("index_read_elapsed");
|
||||
let alive_total_collect = AtomicUsize::new(0);
|
||||
|
||||
|
|
|
@ -309,8 +309,6 @@ impl<'a> SnapshotMinimizer<'a> {
|
|||
} = self
|
||||
.accounts_db()
|
||||
.get_unique_accounts_from_storages(storages.iter());
|
||||
let mut stored_accounts = stored_accounts.into_iter().collect::<Vec<_>>();
|
||||
stored_accounts.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
let keep_accounts_collect = Mutex::new(Vec::with_capacity(stored_accounts.len()));
|
||||
let purge_pubkeys_collect = Mutex::new(Vec::with_capacity(stored_accounts.len()));
|
||||
|
|
Loading…
Reference in New Issue