pass AcctIdxConfig to BucketMapHolder (#19997)

This commit is contained in:
Jeff Washington (jwash) 2021-09-18 09:54:00 -05:00 committed by GitHub
parent bd86f41e18
commit f500c99a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -47,7 +47,7 @@ impl<T: IndexValue> Drop for AccountsIndexStorage<T> {
impl<T: IndexValue> AccountsIndexStorage<T> {
pub fn new(bins: usize, config: &Option<AccountsIndexConfig>) -> AccountsIndexStorage<T> {
let storage = Arc::new(BucketMapHolder::new(bins));
let storage = Arc::new(BucketMapHolder::new(bins, config));
let in_mem = (0..bins)
.into_iter()

View File

@ -1,4 +1,4 @@
use crate::accounts_index::IndexValue;
use crate::accounts_index::{AccountsIndexConfig, IndexValue};
use crate::bucket_map_holder_stats::BucketMapHolderStats;
use crate::waitable_condvar::WaitableCondvar;
use std::fmt::Debug;
@ -49,7 +49,7 @@ impl<T: IndexValue> BucketMapHolder<T> {
self.count_ages_flushed.load(Ordering::Relaxed) >= self.bins
}
pub fn new(bins: usize) -> Self {
pub fn new(bins: usize, _config: &Option<AccountsIndexConfig>) -> Self {
Self {
count_ages_flushed: AtomicUsize::default(),
age: AtomicU8::default(),
@ -83,7 +83,7 @@ pub mod tests {
fn test_next_bucket_to_flush() {
solana_logger::setup();
let bins = 4;
let test = BucketMapHolder::<u64>::new(bins);
let test = BucketMapHolder::<u64>::new(bins, &Some(AccountsIndexConfig::default()));
let visited = (0..bins)
.into_iter()
.map(|_| AtomicUsize::default())
@ -107,7 +107,7 @@ pub mod tests {
fn test_age_increment() {
solana_logger::setup();
let bins = 4;
let test = BucketMapHolder::<u64>::new(bins);
let test = BucketMapHolder::<u64>::new(bins, &Some(AccountsIndexConfig::default()));
for age in 0..513 {
assert_eq!(test.current_age(), (age % 256) as Age);
@ -125,7 +125,7 @@ pub mod tests {
fn test_age_broad() {
solana_logger::setup();
let bins = 4;
let test = BucketMapHolder::<u64>::new(bins);
let test = BucketMapHolder::<u64>::new(bins, &Some(AccountsIndexConfig::default()));
assert_eq!(test.current_age(), 0);
assert!(!test.all_buckets_flushed_at_current_age());
// inc all but 1

View File

@ -378,10 +378,13 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
#[cfg(test)]
mod tests {
use super::*;
use crate::accounts_index::BINS_FOR_TESTING;
use crate::accounts_index::{AccountsIndexConfig, BINS_FOR_TESTING};
fn new_for_test<T: IndexValue>() -> InMemAccountsIndex<T> {
let holder = Arc::new(BucketMapHolder::new(BINS_FOR_TESTING));
let holder = Arc::new(BucketMapHolder::new(
BINS_FOR_TESTING,
&Some(AccountsIndexConfig::default()),
));
InMemAccountsIndex::new(&holder, BINS_FOR_TESTING)
}