init knowhere build/search thread pool; (#26449)

Signed-off-by: cqy123456 <qianya.cheng@zilliz.com>
pull/26432/head
cqy123456 2023-08-18 14:00:19 +08:00 committed by GitHub
parent 065d1a962e
commit fd37860e57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 11 deletions

View File

@ -72,8 +72,13 @@ KnowhereSetSimdType(const char* value) {
}
void
KnowhereInitThreadPool(const uint32_t num_threads) {
knowhere::ThreadPool::InitGlobalThreadPool(num_threads);
KnowhereInitBuildThreadPool(const uint32_t num_threads) {
knowhere::ThreadPool::InitGlobalBuildThreadPool(num_threads);
}
void
KnowhereInitSearchThreadPool(const uint32_t num_threads) {
knowhere::ThreadPool::InitGlobalSearchThreadPool(num_threads);
if (!knowhere::KnowhereConfig::SetAioContextPool(num_threads)) {
PanicInfo("Failed to set aio context pool with num_threads " +
std::to_string(num_threads));

View File

@ -26,6 +26,8 @@ std::string
KnowhereSetSimdType(const char*);
void
KnowhereInitThreadPool(const uint32_t);
KnowhereInitBuildThreadPool(const uint32_t);
void
KnowhereInitSearchThreadPool(const uint32_t);
} // namespace milvus::config

View File

@ -50,8 +50,13 @@ SegcoreSetNprobe(const int64_t value) {
}
extern "C" void
SegcoreSetKnowhereThreadPoolNum(const uint32_t num_threads) {
milvus::config::KnowhereInitThreadPool(num_threads);
SegcoreSetKnowhereBuildThreadPoolNum(const uint32_t num_threads) {
milvus::config::KnowhereInitBuildThreadPool(num_threads);
}
extern "C" void
SegcoreSetKnowhereSearchThreadPoolNum(const uint32_t num_threads) {
milvus::config::KnowhereInitSearchThreadPool(num_threads);
}
// return value must be freed by the caller

View File

@ -35,7 +35,10 @@ char*
SegcoreSetSimdType(const char*);
void
SegcoreSetKnowhereThreadPoolNum(const uint32_t num_threads);
SegcoreSetKnowhereBuildThreadPoolNum(const uint32_t num_threads);
void
SegcoreSetKnowhereSearchThreadPoolNum(const uint32_t num_threads);
void
SegcoreCloseGlog();

View File

@ -11,7 +11,7 @@
# or implied. See the License for the specific language governing permissions and limitations under the License.
#-------------------------------------------------------------------------------
set( KNOWHERE_VERSION aa4a42f )
set( KNOWHERE_VERSION 57a7fcf )
message(STATUS "Building knowhere-${KNOWHERE_SOURCE_VER} from source")
message(STATUS ${CMAKE_BUILD_TYPE})

View File

@ -29,11 +29,11 @@ TEST(Init, Naive) {
TEST(Init, KnowhereThreadPoolInit) {
#ifdef BUILD_DISK_ANN
try {
milvus::config::KnowhereInitThreadPool(0);
milvus::config::KnowhereInitSearchThreadPool(0);
} catch (std::exception& e) {
ASSERT_TRUE(std::string(e.what()).find(
"Failed to set aio context pool") != std::string::npos);
}
#endif
milvus::config::KnowhereInitThreadPool(8);
milvus::config::KnowhereInitSearchThreadPool(8);
}

View File

@ -169,7 +169,7 @@ func (i *IndexNode) initSegcore() {
C.InitCpuNum(cCPUNum)
cKnowhereThreadPoolSize := C.uint32_t(hardware.GetCPUNum() * paramtable.DefaultKnowhereThreadPoolNumRatioInBuild)
C.SegcoreSetKnowhereThreadPoolNum(cKnowhereThreadPoolSize)
C.SegcoreSetKnowhereBuildThreadPoolNum(cKnowhereThreadPoolSize)
localDataRootPath := filepath.Join(Params.LocalStorageCfg.Path.GetValue(), typeutil.IndexNodeRole)
initcore.InitLocalChunkManager(localDataRootPath)

View File

@ -186,7 +186,7 @@ func (node *QueryNode) InitSegcore() error {
C.SegcoreSetChunkRows(cChunkRows)
cKnowhereThreadPoolSize := C.uint32_t(paramtable.Get().QueryNodeCfg.KnowhereThreadPoolSize.GetAsUint32())
C.SegcoreSetKnowhereThreadPoolNum(cKnowhereThreadPoolSize)
C.SegcoreSetKnowhereSearchThreadPoolNum(cKnowhereThreadPoolSize)
enableGrowingIndex := C.bool(paramtable.Get().QueryNodeCfg.EnableGrowingSegmentIndex.GetAsBool())
C.SegcoreSetEnableGrowingSegmentIndex(enableGrowingIndex)