From d8427056226669787c40132617e6eaacbb8626bf Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:50:22 -0500 Subject: [PATCH] AcctIdx: when bg processing in multiple threads, avoid bin collisions (#20019) --- runtime/src/accounts_index_storage.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/src/accounts_index_storage.rs b/runtime/src/accounts_index_storage.rs index 9fe7756701..a82352e7a2 100644 --- a/runtime/src/accounts_index_storage.rs +++ b/runtime/src/accounts_index_storage.rs @@ -96,6 +96,7 @@ impl AccountsIndexStorage { exit: Arc, in_mem: Vec>>, ) { + let bins = in_mem.len(); loop { // this will transition to waits and thread throttling storage @@ -106,11 +107,11 @@ impl AccountsIndexStorage { } 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); } }