AcctIdx: disk index now holds a bucket map (#19995)
This commit is contained in:
parent
7a785e067a
commit
2a42f8a06e
|
@ -1,13 +1,16 @@
|
||||||
use crate::accounts_index::{AccountsIndexConfig, IndexValue};
|
use crate::accounts_index::{AccountsIndexConfig, IndexValue};
|
||||||
use crate::bucket_map_holder_stats::BucketMapHolderStats;
|
use crate::bucket_map_holder_stats::BucketMapHolderStats;
|
||||||
|
use crate::in_mem_accounts_index::SlotT;
|
||||||
use crate::waitable_condvar::WaitableCondvar;
|
use crate::waitable_condvar::WaitableCondvar;
|
||||||
|
use solana_bucket_map::bucket_map::{BucketMap, BucketMapConfig};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
pub type Age = u8;
|
pub type Age = u8;
|
||||||
|
|
||||||
// will eventually hold the bucket map
|
|
||||||
pub struct BucketMapHolder<T: IndexValue> {
|
pub struct BucketMapHolder<T: IndexValue> {
|
||||||
|
pub disk: Option<BucketMap<SlotT<T>>>,
|
||||||
|
|
||||||
pub count_ages_flushed: AtomicUsize,
|
pub count_ages_flushed: AtomicUsize,
|
||||||
pub age: AtomicU8,
|
pub age: AtomicU8,
|
||||||
pub stats: BucketMapHolderStats,
|
pub stats: BucketMapHolderStats,
|
||||||
|
@ -85,7 +88,15 @@ impl<T: IndexValue> BucketMapHolder<T> {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|config| config.ages_to_stay_in_cache)
|
.and_then(|config| config.ages_to_stay_in_cache)
|
||||||
.unwrap_or(DEFAULT_AGE_TO_STAY_IN_CACHE);
|
.unwrap_or(DEFAULT_AGE_TO_STAY_IN_CACHE);
|
||||||
|
|
||||||
|
let mut bucket_config = BucketMapConfig::new(bins);
|
||||||
|
bucket_config.drives = config.as_ref().and_then(|config| config.drives.clone());
|
||||||
|
let mem_budget_mb = config.as_ref().and_then(|config| config.index_limit_mb);
|
||||||
|
// only allocate if mem_budget_mb is Some
|
||||||
|
let disk = mem_budget_mb.map(|_| BucketMap::new(bucket_config));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
disk,
|
||||||
ages_to_stay_in_cache,
|
ages_to_stay_in_cache,
|
||||||
count_ages_flushed: AtomicUsize::default(),
|
count_ages_flushed: AtomicUsize::default(),
|
||||||
age: AtomicU8::default(),
|
age: AtomicU8::default(),
|
||||||
|
@ -94,7 +105,7 @@ impl<T: IndexValue> BucketMapHolder<T> {
|
||||||
next_bucket_to_flush: Mutex::new(0),
|
next_bucket_to_flush: Mutex::new(0),
|
||||||
bins,
|
bins,
|
||||||
startup: AtomicBool::default(),
|
startup: AtomicBool::default(),
|
||||||
mem_budget_mb: config.as_ref().and_then(|config| config.index_limit_mb),
|
mem_budget_mb,
|
||||||
_phantom: std::marker::PhantomData::<T>::default(),
|
_phantom: std::marker::PhantomData::<T>::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue