diff --git a/accounts-db/src/read_only_accounts_cache.rs b/accounts-db/src/read_only_accounts_cache.rs index 57185b1c744561..d89b94420680da 100644 --- a/accounts-db/src/read_only_accounts_cache.rs +++ b/accounts-db/src/read_only_accounts_cache.rs @@ -3,6 +3,7 @@ #[cfg(feature = "dev-context-only-utils")] use qualifier_attr::qualifiers; use { + ahash::random_state::RandomState as AHashRandomState, dashmap::{mapref::entry::Entry, DashMap}, log::*, rand::{ @@ -77,7 +78,7 @@ struct AtomicReadOnlyCacheStats { #[cfg_attr(feature = "dev-context-only-utils", qualifiers(pub))] #[derive(Debug)] pub(crate) struct ReadOnlyAccountsCache { - cache: Arc>, + cache: Arc>, _max_data_size_lo: usize, _max_data_size_hi: usize, data_size: Arc, @@ -103,7 +104,10 @@ impl ReadOnlyAccountsCache { ) -> Self { assert!(max_data_size_lo <= max_data_size_hi); assert!(evict_sample_size > 0); - let cache = Arc::new(DashMap::with_shard_amount(SHARDS)); + let cache = Arc::new(DashMap::with_hasher_and_shard_amount( + AHashRandomState::default(), + SHARDS, + )); let data_size = Arc::new(AtomicUsize::default()); let stats = Arc::new(AtomicReadOnlyCacheStats::default()); let evictor_exit_flag = Arc::new(AtomicBool::new(false)); @@ -210,7 +214,7 @@ impl ReadOnlyAccountsCache { /// Removes `key` from the cache, if present, and returns the removed account fn do_remove( key: &ReadOnlyCacheKey, - cache: &DashMap, + cache: &DashMap, data_size: &AtomicUsize, ) -> Option { let (_, entry) = cache.remove(key)?; @@ -262,7 +266,7 @@ impl ReadOnlyAccountsCache { max_data_size_hi: usize, data_size: Arc, evict_sample_size: usize, - cache: Arc>, + cache: Arc>, stats: Arc, ) -> thread::JoinHandle<()> { thread::Builder::new() @@ -310,7 +314,7 @@ impl ReadOnlyAccountsCache { target_data_size: usize, data_size: &AtomicUsize, evict_sample_size: usize, - cache: &DashMap, + cache: &DashMap, ) -> u64 { let mut rng = thread_rng();