From 3056efda01de9d89c34298ad6e7fac7c078d19cd Mon Sep 17 00:00:00 2001 From: starlord Date: Thu, 8 Aug 2019 10:37:01 +0800 Subject: [PATCH] MS-312 Set openmp thread number by config Former-commit-id: 511a0da7d85a341c0970f2e5823152b5ae2c71db --- cpp/src/server/DBWrapper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpp/src/server/DBWrapper.cpp b/cpp/src/server/DBWrapper.cpp index 4487a37e..fbe630a8 100644 --- a/cpp/src/server/DBWrapper.cpp +++ b/cpp/src/server/DBWrapper.cpp @@ -66,6 +66,12 @@ DBWrapper::DBWrapper() { if(omp_thread > 0) { omp_set_num_threads(omp_thread); SERVER_LOG_DEBUG << "Specify openmp thread number: " << omp_thread; + } else { + uint32_t sys_thread_cnt = 8; + if(CommonUtil::GetSystemAvailableThreads(sys_thread_cnt)) { + omp_thread = (int32_t)ceil(sys_thread_cnt*0.5); + omp_set_num_threads(omp_thread); + } } //set archive config -- GitLab