diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 80df09ad28..ea37ff28c8 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -40,6 +40,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-266 - Improve topk reduce time by using multi-threads - MS-275 - Avoid sqlite logic error excetion - MS-278 - add IndexStatsHelper +- MS-312 - Set openmp thread number by config - MS-305 - add CPU core percent metric - MS-310 - add milvus CPU utilization ratio and CPU/GPU temperature metrics diff --git a/cpp/conf/server_config.template b/cpp/conf/server_config.template index ff5cfc6cd5..11eb9f9eeb 100644 --- a/cpp/conf/server_config.template +++ b/cpp/conf/server_config.template @@ -43,4 +43,5 @@ engine_config: nprobe: 10 nlist: 16384 use_blas_threshold: 20 - metric_type: L2 # compare vectors by euclidean distance(L2) or inner product(IP), optional: L2 or IP + metric_type: L2 # compare vectors by euclidean distance(L2) or inner product(IP), optional: L2 or IP + omp_thread_num: 0 # how many compute threads be used by engine, 0 means use all cpu core to compute diff --git a/cpp/src/server/DBWrapper.cpp b/cpp/src/server/DBWrapper.cpp index e908f62d7c..4487a37e19 100644 --- a/cpp/src/server/DBWrapper.cpp +++ b/cpp/src/server/DBWrapper.cpp @@ -10,11 +10,14 @@ #include "utils/Log.h" #include "utils/StringHelpFunctions.h" +#include + namespace zilliz { namespace milvus { namespace server { DBWrapper::DBWrapper() { + //db config zilliz::milvus::engine::Options opt; ConfigNode& db_config = ServerConfig::GetInstance().GetConfig(CONFIG_DB); opt.meta.backend_uri = db_config.GetValue(CONFIG_DB_URL); @@ -37,6 +40,7 @@ DBWrapper::DBWrapper() { kill(0, SIGUSR1); } + // cache config ConfigNode& cache_config = ServerConfig::GetInstance().GetConfig(CONFIG_CACHE); opt.insert_cache_immediately_ = cache_config.GetBoolValue(CONFIG_INSERT_CACHE_IMMEDIATELY, false); @@ -56,6 +60,14 @@ DBWrapper::DBWrapper() { kill(0, SIGUSR1); } + // engine config + ConfigNode& engine_config = ServerConfig::GetInstance().GetConfig(CONFIG_ENGINE); + int32_t omp_thread = engine_config.GetInt32Value(CONFIG_OMP_THREAD_NUM, 0); + if(omp_thread > 0) { + omp_set_num_threads(omp_thread); + SERVER_LOG_DEBUG << "Specify openmp thread number: " << omp_thread; + } + //set archive config engine::ArchiveConf::CriteriaT criterial; int64_t disk = db_config.GetInt64Value(CONFIG_DB_ARCHIVE_DISK, 0); diff --git a/cpp/src/server/ServerConfig.h b/cpp/src/server/ServerConfig.h index bb7d5d3669..e899d1f8d6 100644 --- a/cpp/src/server/ServerConfig.h +++ b/cpp/src/server/ServerConfig.h @@ -53,6 +53,7 @@ static const std::string CONFIG_NPROBE = "nprobe"; static const std::string CONFIG_NLIST = "nlist"; static const std::string CONFIG_DCBT = "use_blas_threshold"; static const std::string CONFIG_METRICTYPE = "metric_type"; +static const std::string CONFIG_OMP_THREAD_NUM = "omp_thread_num"; class ServerConfig { public: