AcctIdx: only flush if disk index being used (#20045)

This commit is contained in:
Jeff Washington (jwash) 2021-09-21 08:42:13 -05:00 committed by GitHub
parent 38ea3aa31a
commit bbe151e594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -97,6 +97,7 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
in_mem: Vec<Arc<InMemAccountsIndex<T>>>,
) {
let bins = in_mem.len();
let flush = storage.disk.is_some();
loop {
// this will transition to waits and thread throttling
storage
@ -108,8 +109,10 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
storage.stats.active_threads.fetch_add(1, Ordering::Relaxed);
for _ in 0..bins {
let index = storage.next_bucket_to_flush();
in_mem[index].flush();
if flush {
let index = storage.next_bucket_to_flush();
in_mem[index].flush();
}
storage.stats.report_stats(&storage);
}
storage.stats.active_threads.fetch_sub(1, Ordering::Relaxed);