提交 eee85889 编写于 作者: G groot

MS-312 Set openmp thread number by config


Former-commit-id: 4c5b32f30e68639d85f4ae1d3eb8115810d8af01
上级 817b24ae
......@@ -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
## New Feature
- MS-180 - Add new mem manager
......
......@@ -44,3 +44,4 @@ engine_config:
nlist: 16384
use_blas_threshold: 20
metric_type: L2 # compare vectors by euclidean distance(L2) or inner product(IP), optional: L2 or IP
omp_thread_occupancy: 0.75 # how many compute threads be used, this is a percent value compare to system cpu core number(for instance: cpu core is 4, then 0.75 means use 3 compute threads)
......@@ -10,11 +10,14 @@
#include "utils/Log.h"
#include "utils/StringHelpFunctions.h"
#include <omp.h>
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,16 @@ DBWrapper::DBWrapper() {
kill(0, SIGUSR1);
}
// engine config
ConfigNode& engine_config = ServerConfig::GetInstance().GetConfig(CONFIG_ENGINE);
float omp_thread_rate = engine_config.GetFloatValue(CONFIG_OMP_THREAD_RATE, 0.75);
uint32_t cpu_count = 1;
CommonUtil::GetSystemAvailableThreads(cpu_count);
float thread_count = omp_thread_rate*(float)cpu_count;
int32_t omp_thread = (int32_t)round(thread_count);
omp_set_num_threads(omp_thread);
SERVER_LOG_DEBUG << "Openmp thread number = " << omp_thread;
//set archive config
engine::ArchiveConf::CriteriaT criterial;
int64_t disk = db_config.GetInt64Value(CONFIG_DB_ARCHIVE_DISK, 0);
......
......@@ -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_RATE = "omp_thread_occupancy";
class ServerConfig {
public:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册