allocate threads for accounts idx based on cpus (#20118)

This commit is contained in:
Jeff Washington (jwash) 2021-09-27 11:25:06 -05:00 committed by GitHub
parent 025261c05e
commit bc50fd4ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -44,11 +44,11 @@ impl<T: IndexValue> Drop for AccountsIndexStorage<T> {
impl<T: IndexValue> AccountsIndexStorage<T> {
pub fn new(bins: usize, config: &Option<AccountsIndexConfig>) -> AccountsIndexStorage<T> {
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));