mem idx tracks duplicates better (#30701)

This commit is contained in:
Jeff Washington (jwash) 2023-03-14 09:26:39 -05:00 committed by GitHub
parent 560ec08d5e
commit 89d5efa0d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -4,7 +4,7 @@ use {
ancestors::Ancestors,
bucket_map_holder::{Age, BucketMapHolder},
contains::Contains,
in_mem_accounts_index::InMemAccountsIndex,
in_mem_accounts_index::{InMemAccountsIndex, InsertNewEntryResults},
inline_spl_token::{self, GenericTokenAccount},
inline_spl_token_2022,
pubkey_bins::PubkeyBinCalculator24,
@ -1637,7 +1637,7 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
(pubkey_bin, Vec::with_capacity(expected_items_per_bin))
})
.collect::<Vec<_>>();
let dirty_pubkeys = items
let mut dirty_pubkeys = items
.filter_map(|(pubkey, account_info)| {
let pubkey_bin = self.bin_calculator.bin_from_pubkey(&pubkey);
let binned_index = (pubkey_bin + random_offset) % bins;
@ -1668,7 +1668,13 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
&self.storage.storage,
use_disk,
);
r_account_maps.insert_new_entry_if_missing_with_lock(pubkey, new_entry);
match r_account_maps.insert_new_entry_if_missing_with_lock(pubkey, new_entry) {
InsertNewEntryResults::DidNotExist => {}
InsertNewEntryResults::ExistedNewEntryZeroLamports => {}
InsertNewEntryResults::ExistedNewEntryNonZeroLamports => {
dirty_pubkeys.push(pubkey);
}
}
});
}
insert_time.stop();