AcctIdx: when bg processing in multiple threads, avoid bin collisions (#20019)

This commit is contained in:
Jeff Washington (jwash) 2021-09-20 11:50:22 -05:00 committed by GitHub
parent d6d2840c94
commit d842705622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -96,6 +96,7 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
exit: Arc<AtomicBool>,
in_mem: Vec<Arc<InMemAccountsIndex<T>>>,
) {
let bins = in_mem.len();
loop {
// this will transition to waits and thread throttling
storage
@ -106,11 +107,11 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
}
storage.stats.active_threads.fetch_add(1, Ordering::Relaxed);
for bucket in &in_mem {
bucket.flush();
for _ in 0..bins {
let index = storage.next_bucket_to_flush();
in_mem[index].flush();
storage.stats.report_stats();
}
storage.stats.report_stats();
storage.stats.active_threads.fetch_sub(1, Ordering::Relaxed);
}
}