diff --git a/include/collection_manager.h b/include/collection_manager.h index a1102d7d..23c74f06 100644 --- a/include/collection_manager.h +++ b/include/collection_manager.h @@ -71,9 +71,6 @@ private: std::atomic max_memory_ratio; - /// During load, sleep `LOAD_THROTTLE_PERCENT`% of time taken for indexing to prevent CPU saturation - float LOAD_THROTTLE_PERCENT = 10; - CollectionManager(); ~CollectionManager() = default; diff --git a/include/config.h b/include/config.h index 3fdbf88c..db71aa98 100644 --- a/include/config.h +++ b/include/config.h @@ -40,10 +40,10 @@ private: int log_slow_requests_time_ms; - size_t num_collections_parallel_load; - size_t num_documents_parallel_load; + uint32_t num_collections_parallel_load; + uint32_t num_documents_parallel_load; - size_t thread_pool_size; + uint32_t thread_pool_size; protected: @@ -57,11 +57,9 @@ protected: this->catch_up_min_sequence_diff = 3000; this->catch_up_threshold_percentage = 95; this->log_slow_requests_time_ms = -1; - this->num_collections_parallel_load = 4; + this->num_collections_parallel_load = 0; // will be set dynamically if not overridden this->num_documents_parallel_load = 1000; - - // will be set dynamically if not overridden - this->thread_pool_size = 0; + this->thread_pool_size = 0; // will be set dynamically if not overridden } Config(Config const&) { @@ -401,7 +399,7 @@ public: } if(reader.Exists("server", "num-collections-parallel-load")) { - this->num_collections_parallel_load = (int) reader.GetInteger("server", "num-collections-parallel-load", 4); + this->num_collections_parallel_load = (int) reader.GetInteger("server", "num-collections-parallel-load", 0); } if(reader.Exists("server", "num-documents-parallel-load")) { @@ -492,19 +490,19 @@ public: } if(options.exist("log-slow-requests-time-ms")) { - this->log_slow_requests_time_ms = options.exist("log-slow-requests-time-ms"); + this->log_slow_requests_time_ms = options.get("log-slow-requests-time-ms"); } if(options.exist("num-collections-parallel-load")) { - this->num_collections_parallel_load = options.exist("num-collections-parallel-load"); + this->num_collections_parallel_load = options.get("num-collections-parallel-load"); } if(options.exist("num-documents-parallel-load")) { - this->num_documents_parallel_load = options.exist("num-documents-parallel-load"); + this->num_documents_parallel_load = options.get("num-documents-parallel-load"); } if(options.exist("thread-pool-size")) { - this->thread_pool_size = options.exist("thread-pool-size"); + this->thread_pool_size = options.get("thread-pool-size"); } } diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cpp index 62603c1e..596b1bf5 100644 --- a/src/typesense_server_utils.cpp +++ b/src/typesense_server_utils.cpp @@ -347,7 +347,11 @@ int run_server(const Config & config, const std::string & version, void (*master size_t thread_pool_size = config.get_thread_pool_size(); const size_t proc_count = std::max(1, std::thread::hardware_concurrency()); - const size_t num_threads = thread_pool_size == 0 ? std::max(proc_count * 8, 16) : thread_pool_size; + const size_t num_threads = thread_pool_size == 0 ? (proc_count * 8) : thread_pool_size; + + size_t num_collections_parallel_load = config.get_num_collections_parallel_load(); + num_collections_parallel_load = (num_collections_parallel_load == 0) ? + (proc_count * 4) : num_collections_parallel_load; LOG(INFO) << "Thread pool size: " << num_threads; ThreadPool app_thread_pool(num_threads); @@ -385,7 +389,7 @@ int run_server(const Config & config, const std::string & version, void (*master ReplicationState replication_state(&store, &app_thread_pool, server->get_message_dispatcher(), ssl_enabled, config.get_catch_up_min_sequence_diff(), config.get_catch_up_threshold_percentage(), - config.get_num_collections_parallel_load(), + num_collections_parallel_load, config.get_num_documents_parallel_load()); std::thread raft_thread([&replication_state, &config, &state_dir, &app_thread_pool, &server_thread_pool]() {