From 236c8ee50f42f5d328b6f5e62f63aeb5fdf81c17 Mon Sep 17 00:00:00 2001 From: Evance Souamoro Date: Thu, 6 May 2021 07:57:16 +0000 Subject: [PATCH] fix bug from max to min --- src/core/index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/index.rs b/src/core/index.rs index c011746d93..a683fd6aaa 100644 --- a/src/core/index.rs +++ b/src/core/index.rs @@ -442,7 +442,7 @@ impl Index { /// # Panics /// If the heap size per thread is too small, panics. pub fn writer(&self, overall_heap_size_in_bytes: usize) -> crate::Result { - let mut num_threads = std::cmp::max(num_cpus::get(), MAX_NUM_THREAD); + let mut num_threads = std::cmp::min(num_cpus::get(), MAX_NUM_THREAD); let heap_size_in_bytes_per_thread = overall_heap_size_in_bytes / num_threads; if heap_size_in_bytes_per_thread < HEAP_SIZE_MIN { num_threads = (overall_heap_size_in_bytes / HEAP_SIZE_MIN).max(1);