sort shrink acct indexes (#20708)

This commit is contained in:
Jeff Washington (jwash) 2021-10-18 09:06:32 -05:00 committed by GitHub
parent d12b724e04
commit 0d934d311e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2471,7 +2471,7 @@ impl AccountsDb {
unrefed_pubkeys: &mut Vec<&'a Pubkey>,
) -> usize
where
I: Iterator<Item = (&'a Pubkey, &'a FoundStoredAccount<'a>)>,
I: Iterator<Item = &'a (Pubkey, FoundStoredAccount<'a>)>,
{
let mut alive_total = 0;
@ -2544,6 +2544,10 @@ impl AccountsDb {
num_stores += 1;
}
// 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);