AcctIdx: pass bins to BucketMapHolder (#19906)
This commit is contained in:
parent
99f2c746d1
commit
eddd583cd5
|
@ -742,7 +742,7 @@ impl<T: IndexValue> AccountsIndex<T> {
|
||||||
.unwrap_or(BINS_DEFAULT);
|
.unwrap_or(BINS_DEFAULT);
|
||||||
// create bin_calculator early to verify # bins is reasonable
|
// create bin_calculator early to verify # bins is reasonable
|
||||||
let bin_calculator = PubkeyBinCalculator16::new(bins);
|
let bin_calculator = PubkeyBinCalculator16::new(bins);
|
||||||
let storage = AccountsIndexStorage::new();
|
let storage = AccountsIndexStorage::new(bins);
|
||||||
let account_maps = (0..bins)
|
let account_maps = (0..bins)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|bin| RwLock::new(Arc::new(InMemAccountsIndex::new(&storage, bin))))
|
.map(|bin| RwLock::new(Arc::new(InMemAccountsIndex::new(&storage, bin))))
|
||||||
|
|
|
@ -14,8 +14,6 @@ use std::{
|
||||||
// Also manages the lifetime of the background processing threads.
|
// Also manages the lifetime of the background processing threads.
|
||||||
// When this instance is dropped, it will drop the bucket map and cleanup
|
// When this instance is dropped, it will drop the bucket map and cleanup
|
||||||
// and it will stop all the background threads and join them.
|
// and it will stop all the background threads and join them.
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct AccountsIndexStorage<T: IndexValue> {
|
pub struct AccountsIndexStorage<T: IndexValue> {
|
||||||
// for managing the bg threads
|
// for managing the bg threads
|
||||||
exit: Arc<AtomicBool>,
|
exit: Arc<AtomicBool>,
|
||||||
|
@ -43,8 +41,8 @@ impl<T: IndexValue> Drop for AccountsIndexStorage<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: IndexValue> AccountsIndexStorage<T> {
|
impl<T: IndexValue> AccountsIndexStorage<T> {
|
||||||
pub fn new() -> AccountsIndexStorage<T> {
|
pub fn new(bins: usize) -> AccountsIndexStorage<T> {
|
||||||
let storage = Arc::new(BucketMapHolder::new());
|
let storage = Arc::new(BucketMapHolder::new(bins));
|
||||||
let storage_ = storage.clone();
|
let storage_ = storage.clone();
|
||||||
let exit = Arc::new(AtomicBool::default());
|
let exit = Arc::new(AtomicBool::default());
|
||||||
let exit_ = exit.clone();
|
let exit_ = exit.clone();
|
||||||
|
|
|
@ -7,7 +7,6 @@ use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
// will eventually hold the bucket map
|
// will eventually hold the bucket map
|
||||||
#[derive(Default)]
|
|
||||||
pub struct BucketMapHolder<T: IndexValue> {
|
pub struct BucketMapHolder<T: IndexValue> {
|
||||||
pub stats: BucketMapHolderStats,
|
pub stats: BucketMapHolderStats,
|
||||||
_phantom: std::marker::PhantomData<T>,
|
_phantom: std::marker::PhantomData<T>,
|
||||||
|
@ -20,8 +19,11 @@ impl<T: IndexValue> Debug for BucketMapHolder<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: IndexValue> BucketMapHolder<T> {
|
impl<T: IndexValue> BucketMapHolder<T> {
|
||||||
pub fn new() -> Self {
|
pub fn new(_bins: usize) -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
stats: BucketMapHolderStats::default(),
|
||||||
|
_phantom: std::marker::PhantomData::<T>::default(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// intended to execute in a bg thread
|
// intended to execute in a bg thread
|
||||||
|
|
|
@ -41,10 +41,6 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||||
&self.map_internal
|
&self.map_internal
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_bucket_map_holder() -> Arc<BucketMapHolder<T>> {
|
|
||||||
Arc::new(BucketMapHolder::new())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn items<R>(&self, range: &Option<&R>) -> Vec<(K, AccountMapEntry<T>)>
|
pub fn items<R>(&self, range: &Option<&R>) -> Vec<(K, AccountMapEntry<T>)>
|
||||||
where
|
where
|
||||||
R: RangeBounds<Pubkey> + std::fmt::Debug,
|
R: RangeBounds<Pubkey> + std::fmt::Debug,
|
||||||
|
|
Loading…
Reference in New Issue