From bc50fd4ad638b4161bcb1032df719f548ff9cc68 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:25:06 -0500 Subject: [PATCH] allocate threads for accounts idx based on cpus (#20118) --- runtime/src/accounts_index_storage.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/src/accounts_index_storage.rs b/runtime/src/accounts_index_storage.rs index 9781d702df..74ab683b69 100644 --- a/runtime/src/accounts_index_storage.rs +++ b/runtime/src/accounts_index_storage.rs @@ -44,11 +44,11 @@ impl Drop for AccountsIndexStorage { impl AccountsIndexStorage { pub fn new(bins: usize, config: &Option) -> AccountsIndexStorage { - const DEFAULT_THREADS: usize = 1; // soon, this will be a cpu calculation + let num_threads = std::cmp::max(2, num_cpus::get() / 4); let threads = config .as_ref() .and_then(|config| config.flush_threads) - .unwrap_or(DEFAULT_THREADS); + .unwrap_or(num_threads); let storage = Arc::new(BucketMapHolder::new(bins, config, threads));