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

Replaces DashMap with HashMap in secondary indexes #1137

Merged
merged 3 commits into from
May 2, 2024
Merged
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
38 changes: 20 additions & 18 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ pub enum AccountsIndexScanResult {
pub struct AccountsIndex<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> {
pub account_maps: LockMapType<T, U>,
pub bin_calculator: PubkeyBinCalculator24,
program_id_index: SecondaryIndex<DashMapSecondaryIndexEntry>,
spl_token_mint_index: SecondaryIndex<DashMapSecondaryIndexEntry>,
program_id_index: SecondaryIndex<RwLockSecondaryIndexEntry>,
spl_token_mint_index: SecondaryIndex<RwLockSecondaryIndexEntry>,
spl_token_owner_index: SecondaryIndex<RwLockSecondaryIndexEntry>,
pub roots_tracker: RwLock<RootsTracker>,
ongoing_scan_roots: RwLock<BTreeMap<Slot, u64>>,
Expand Down Expand Up @@ -683,10 +683,10 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
Self {
account_maps,
bin_calculator,
program_id_index: SecondaryIndex::<DashMapSecondaryIndexEntry>::new(
program_id_index: SecondaryIndex::<RwLockSecondaryIndexEntry>::new(
"program_id_index_stats",
),
spl_token_mint_index: SecondaryIndex::<DashMapSecondaryIndexEntry>::new(
spl_token_mint_index: SecondaryIndex::<RwLockSecondaryIndexEntry>::new(
"spl_token_mint_index_stats",
),
spl_token_owner_index: SecondaryIndex::<RwLockSecondaryIndexEntry>::new(
Expand Down Expand Up @@ -2050,17 +2050,17 @@ pub mod tests {
}
}

fn create_dashmap_secondary_index_state() -> (usize, usize, AccountSecondaryIndexes) {
fn create_spl_token_mint_secondary_index_state() -> (usize, usize, AccountSecondaryIndexes) {
{
// Check that we're actually testing the correct variant
let index = AccountsIndex::<bool, bool>::default_for_tests();
let _type_check = SecondaryIndexTypes::DashMap(&index.spl_token_mint_index);
let _type_check = SecondaryIndexTypes::RwLock(&index.spl_token_mint_index);
}

(0, PUBKEY_BYTES, spl_token_mint_index_enabled())
}

fn create_rwlock_secondary_index_state() -> (usize, usize, AccountSecondaryIndexes) {
fn create_spl_token_owner_secondary_index_state() -> (usize, usize, AccountSecondaryIndexes) {
{
// Check that we're actually testing the correct variant
let index = AccountsIndex::<bool, bool>::default_for_tests();
Expand Down Expand Up @@ -3436,8 +3436,8 @@ pub mod tests {
}

#[test]
fn test_purge_exact_dashmap_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_dashmap_secondary_index_state();
fn test_purge_exact_spl_token_mint_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_spl_token_mint_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
run_test_purge_exact_secondary_index(
&index,
Expand All @@ -3449,8 +3449,9 @@ pub mod tests {
}

#[test]
fn test_purge_exact_rwlock_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_rwlock_secondary_index_state();
fn test_purge_exact_spl_token_owner_secondary_index() {
let (key_start, key_end, secondary_indexes) =
create_spl_token_owner_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
run_test_purge_exact_secondary_index(
&index,
Expand Down Expand Up @@ -3654,8 +3655,8 @@ pub mod tests {
}

#[test]
fn test_dashmap_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_dashmap_secondary_index_state();
fn test_spl_token_mint_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_spl_token_mint_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
run_test_spl_token_secondary_indexes(
Expand All @@ -3670,8 +3671,9 @@ pub mod tests {
}

#[test]
fn test_rwlock_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_rwlock_secondary_index_state();
fn test_spl_token_owner_secondary_index() {
let (key_start, key_end, secondary_indexes) =
create_spl_token_owner_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
run_test_spl_token_secondary_indexes(
Expand Down Expand Up @@ -3775,8 +3777,8 @@ pub mod tests {
}

#[test]
fn test_dashmap_secondary_index_same_slot_and_forks() {
let (key_start, key_end, account_index) = create_dashmap_secondary_index_state();
fn test_spl_token_mint_secondary_index_same_slot_and_forks() {
let (key_start, key_end, account_index) = create_spl_token_mint_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
run_test_secondary_indexes_same_slot_and_forks(
Expand All @@ -3792,7 +3794,7 @@ pub mod tests {

#[test]
fn test_rwlock_secondary_index_same_slot_and_forks() {
let (key_start, key_end, account_index) = create_rwlock_secondary_index_state();
let (key_start, key_end, account_index) = create_spl_token_owner_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
run_test_secondary_indexes_same_slot_and_forks(
Expand Down
Loading