Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Scale thread pool size based on number of cores.

kishorenc873bafed2d60
diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cpp
index fb5ee8a4..31281580 100644
--- a/src/typesense_server_utils.cpp
+++ b/src/typesense_server_utils.cpp
@@ -361,7 +361,11 @@ int run_server(const Config & config, const std::string & version, void (*master
create_init_db_snapshot = true;
}
- ThreadPool thread_pool(32);
+ const size_t proc_count = std::max<size_t>(1, std::thread::hardware_concurrency());
+ const size_t num_threads = std::max<size_t>(proc_count * 8, 16);
+
+ LOG(INFO) << "Thread pool size: " << num_threads;
+ ThreadPool thread_pool(num_threads);
Store store(db_dir);
CollectionManager & collectionManager = CollectionManager::get_instance();