AccountsIndexStorage holds InMemAccountsIndex[] (#19947)
This commit is contained in:
committed by
GitHub
parent
49d3d79459
commit
66e0fafc21
@ -745,7 +745,7 @@ impl<T: IndexValue> AccountsIndex<T> {
|
|||||||
let storage = AccountsIndexStorage::new(bins);
|
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::clone(&storage.in_mem[bin])))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
(account_maps, bin_calculator, storage)
|
(account_maps, bin_calculator, storage)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::accounts_index::IndexValue;
|
use crate::accounts_index::IndexValue;
|
||||||
use crate::bucket_map_holder::BucketMapHolder;
|
use crate::bucket_map_holder::BucketMapHolder;
|
||||||
|
use crate::in_mem_accounts_index::InMemAccountsIndex;
|
||||||
use crate::waitable_condvar::WaitableCondvar;
|
use crate::waitable_condvar::WaitableCondvar;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::{
|
use std::{
|
||||||
@ -22,6 +23,7 @@ pub struct AccountsIndexStorage<T: IndexValue> {
|
|||||||
|
|
||||||
// eventually the backing storage
|
// eventually the backing storage
|
||||||
storage: Arc<BucketMapHolder<T>>,
|
storage: Arc<BucketMapHolder<T>>,
|
||||||
|
pub in_mem: Vec<Arc<InMemAccountsIndex<T>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: IndexValue> Debug for AccountsIndexStorage<T> {
|
impl<T: IndexValue> Debug for AccountsIndexStorage<T> {
|
||||||
@ -43,6 +45,12 @@ impl<T: IndexValue> Drop for AccountsIndexStorage<T> {
|
|||||||
impl<T: IndexValue> AccountsIndexStorage<T> {
|
impl<T: IndexValue> AccountsIndexStorage<T> {
|
||||||
pub fn new(bins: usize) -> AccountsIndexStorage<T> {
|
pub fn new(bins: usize) -> AccountsIndexStorage<T> {
|
||||||
let storage = Arc::new(BucketMapHolder::new(bins));
|
let storage = Arc::new(BucketMapHolder::new(bins));
|
||||||
|
|
||||||
|
let in_mem = (0..bins)
|
||||||
|
.into_iter()
|
||||||
|
.map(|bin| Arc::new(InMemAccountsIndex::new(&storage, bin)))
|
||||||
|
.collect();
|
||||||
|
|
||||||
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();
|
||||||
@ -62,6 +70,7 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
|
|||||||
wait,
|
wait,
|
||||||
handle,
|
handle,
|
||||||
storage,
|
storage,
|
||||||
|
in_mem,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ impl<T: IndexValue> BucketMapHolder<T> {
|
|||||||
_phantom: std::marker::PhantomData::<T>::default(),
|
_phantom: std::marker::PhantomData::<T>::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// intended to execute in a bg thread
|
// intended to execute in a bg thread
|
||||||
pub fn background(&self, exit: Arc<AtomicBool>, wait: Arc<WaitableCondvar>) {
|
pub fn background(&self, exit: Arc<AtomicBool>, wait: Arc<WaitableCondvar>) {
|
||||||
loop {
|
loop {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::accounts_index::{
|
use crate::accounts_index::{
|
||||||
AccountMapEntry, AccountMapEntryInner, IndexValue, SlotList, WriteAccountMapEntry,
|
AccountMapEntry, AccountMapEntryInner, IndexValue, SlotList, WriteAccountMapEntry,
|
||||||
};
|
};
|
||||||
use crate::accounts_index_storage::AccountsIndexStorage;
|
|
||||||
use crate::bucket_map_holder::BucketMapHolder;
|
use crate::bucket_map_holder::BucketMapHolder;
|
||||||
use crate::bucket_map_holder_stats::BucketMapHolderStats;
|
use crate::bucket_map_holder_stats::BucketMapHolderStats;
|
||||||
use solana_measure::measure::Measure;
|
use solana_measure::measure::Measure;
|
||||||
@ -29,10 +28,10 @@ impl<T: IndexValue> Debug for InMemAccountsIndex<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: IndexValue> InMemAccountsIndex<T> {
|
impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||||
pub fn new(storage: &AccountsIndexStorage<T>, bin: usize) -> Self {
|
pub fn new(storage: &Arc<BucketMapHolder<T>>, bin: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
map_internal: RwLock::default(),
|
map_internal: RwLock::default(),
|
||||||
storage: storage.storage().clone(),
|
storage: Arc::clone(storage),
|
||||||
bin,
|
bin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user