From 48283d0d7620b35eaab810db3929f9c9af88be47 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 20 Mar 2024 16:52:08 +0100 Subject: [PATCH] feat: use less threads for short lists --- lib_vector_search/src/grouped_finder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_vector_search/src/grouped_finder.cpp b/lib_vector_search/src/grouped_finder.cpp index 3b4243f..81ec7f8 100644 --- a/lib_vector_search/src/grouped_finder.cpp +++ b/lib_vector_search/src/grouped_finder.cpp @@ -22,7 +22,8 @@ GroupedFinder::find_prefix(std::string_view search_term) const { const auto word_list = group->second; const auto word_list_size = word_list.size(); - const auto thread_count = std::thread::hardware_concurrency(); + const auto thread_count = + std::min(std::thread::hardware_concurrency(), word_list_size); forward_list matching_words; mutex matching_words_mutex;