AcctIdx: rework timing of bg loop (#20077)
This commit is contained in:
committed by
GitHub
parent
a6aef76f52
commit
804ed825f7
@ -1,5 +1,5 @@
|
|||||||
use crate::accounts_index::{AccountsIndexConfig, IndexValue};
|
use crate::accounts_index::{AccountsIndexConfig, IndexValue};
|
||||||
use crate::bucket_map_holder::BucketMapHolder;
|
use crate::bucket_map_holder::{BucketMapHolder, AGE_MS};
|
||||||
use crate::in_mem_accounts_index::InMemAccountsIndex;
|
use crate::in_mem_accounts_index::InMemAccountsIndex;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -99,14 +99,15 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
|
|||||||
let bins = in_mem.len();
|
let bins = in_mem.len();
|
||||||
let flush = storage.disk.is_some();
|
let flush = storage.disk.is_some();
|
||||||
loop {
|
loop {
|
||||||
// this will transition to waits and thread throttling
|
// this will transition to thread throttling
|
||||||
storage
|
storage
|
||||||
.wait_dirty_or_aged
|
.wait_dirty_or_aged
|
||||||
.wait_timeout(Duration::from_millis(10000));
|
.wait_timeout(Duration::from_millis(AGE_MS));
|
||||||
if exit.load(Ordering::Relaxed) {
|
if exit.load(Ordering::Relaxed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storage.maybe_advance_age();
|
||||||
storage.stats.active_threads.fetch_add(1, Ordering::Relaxed);
|
storage.stats.active_threads.fetch_add(1, Ordering::Relaxed);
|
||||||
for _ in 0..bins {
|
for _ in 0..bins {
|
||||||
if flush {
|
if flush {
|
||||||
|
@ -10,7 +10,7 @@ use std::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering};
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
pub type Age = u8;
|
pub type Age = u8;
|
||||||
|
|
||||||
const AGE_MS: u64 = SLOT_MS; // match one age per slot time
|
pub const AGE_MS: u64 = SLOT_MS; // match one age per slot time
|
||||||
|
|
||||||
pub struct BucketMapHolder<T: IndexValue> {
|
pub struct BucketMapHolder<T: IndexValue> {
|
||||||
pub disk: Option<BucketMap<SlotT<T>>>,
|
pub disk: Option<BucketMap<SlotT<T>>>,
|
||||||
|
Reference in New Issue
Block a user