From f330d9f902a1de1f627aeafe29763a33c282f1f9 Mon Sep 17 00:00:00 2001 From: "yudong.cai" Date: Tue, 3 Dec 2019 11:47:10 +0800 Subject: [PATCH] #658 Milvus error out when building SQ8H index without GPU resources --- CHANGELOG.md | 1 + core/src/db/engine/ExecutionEngineImpl.cpp | 6 +++++- core/src/scheduler/task/BuildIndexTask.cpp | 16 ++++------------ .../sdk/examples/partition/src/ClientTest.cpp | 7 ++----- core/src/sdk/examples/simple/src/ClientTest.cpp | 5 +---- core/src/sdk/examples/utils/Utils.cpp | 3 +-- 6 files changed, 14 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e978754cd..51409451b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Please mark all change in change log and use the ticket from JIRA. - \#631 - FAISS isn't compiled with O3 option - \#649 - Typo "partiton" should be "partition" - \#654 - Random crash when frequently insert vector one by one +- \#658 - Milvus error out when building SQ8H index without GPU resources ## Feature - \#12 - Pure CPU version for Milvus diff --git a/core/src/db/engine/ExecutionEngineImpl.cpp b/core/src/db/engine/ExecutionEngineImpl.cpp index f3fd4a67cf..4267c2e903 100644 --- a/core/src/db/engine/ExecutionEngineImpl.cpp +++ b/core/src/db/engine/ExecutionEngineImpl.cpp @@ -121,7 +121,11 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) { } #ifdef CUSTOMIZATION case EngineType::FAISS_IVFSQ8H: { - index = GetVecIndexFactory(IndexType::FAISS_IVFSQ8_HYBRID); + if (gpu_resource_enable) { + index = GetVecIndexFactory(IndexType::FAISS_IVFSQ8_HYBRID); + } else { + throw Exception(DB_ERROR, "No GPU resources for IVFSQ8H"); + } break; } #endif diff --git a/core/src/scheduler/task/BuildIndexTask.cpp b/core/src/scheduler/task/BuildIndexTask.cpp index 571bb279a3..b60de0a1a3 100644 --- a/core/src/scheduler/task/BuildIndexTask.cpp +++ b/core/src/scheduler/task/BuildIndexTask.cpp @@ -19,6 +19,7 @@ #include "db/engine/EngineFactory.h" #include "metrics/Metrics.h" #include "scheduler/job/BuildIndexJob.h" +#include "utils/Exception.h" #include "utils/Log.h" #include "utils/TimeRecorder.h" @@ -129,24 +130,15 @@ XBuildIndexTask::Execute() { try { index = to_index_engine_->BuildIndex(table_file.location_, (EngineType)table_file.engine_type_); if (index == nullptr) { - table_file.file_type_ = engine::meta::TableFileSchema::TO_DELETE; - status = meta_ptr->UpdateTableFile(table_file); - ENGINE_LOG_DEBUG << "Failed to update file to index, mark file: " << table_file.file_id_ - << " to to_delete"; - - build_index_job->BuildIndexDone(to_index_id_); - to_index_engine_ = nullptr; - return; + throw Exception(DB_ERROR, "index NULL"); } } catch (std::exception& ex) { - std::string msg = "BuildIndex encounter exception: " + std::string(ex.what()); + std::string msg = "Build index exception: " + std::string(ex.what()); ENGINE_LOG_ERROR << msg; table_file.file_type_ = engine::meta::TableFileSchema::TO_DELETE; status = meta_ptr->UpdateTableFile(table_file); - ENGINE_LOG_DEBUG << "Failed to update file to index, mark file: " << table_file.file_id_ << " to to_delete"; - - ENGINE_LOG_ERROR << "Failed to build index, index file is too large or gpu memory is not enough"; + ENGINE_LOG_DEBUG << "Build index fail, mark file: " << table_file.file_id_ << " to to_delete"; build_index_job->BuildIndexDone(to_index_id_); build_index_job->GetStatus() = Status(DB_ERROR, msg); diff --git a/core/src/sdk/examples/partition/src/ClientTest.cpp b/core/src/sdk/examples/partition/src/ClientTest.cpp index 7a4bd43cb0..6188c2d4b4 100644 --- a/core/src/sdk/examples/partition/src/ClientTest.cpp +++ b/core/src/sdk/examples/partition/src/ClientTest.cpp @@ -17,15 +17,12 @@ #include "sdk/examples/partition/src/ClientTest.h" #include "MilvusApi.h" +#include "sdk/examples/utils/TimeRecorder.h" #include "sdk/examples/utils/Utils.h" -#include -#include -#include #include #include #include -#include #include #include @@ -42,7 +39,7 @@ constexpr int64_t TOP_K = 10; constexpr int64_t NPROBE = 32; constexpr int64_t SEARCH_TARGET = 5000; // change this value, result is different constexpr milvus::IndexType INDEX_TYPE = milvus::IndexType::IVFSQ8; -constexpr int32_t N_LIST = 15000; +constexpr int32_t N_LIST = 16384; constexpr int32_t PARTITION_COUNT = 5; constexpr int32_t TARGET_PARTITION = 3; diff --git a/core/src/sdk/examples/simple/src/ClientTest.cpp b/core/src/sdk/examples/simple/src/ClientTest.cpp index 14bd059f93..a383701195 100644 --- a/core/src/sdk/examples/simple/src/ClientTest.cpp +++ b/core/src/sdk/examples/simple/src/ClientTest.cpp @@ -20,11 +20,8 @@ #include "sdk/examples/utils/TimeRecorder.h" #include "sdk/examples/utils/Utils.h" -#include -#include #include #include -#include #include #include @@ -42,7 +39,7 @@ constexpr int64_t NPROBE = 32; constexpr int64_t SEARCH_TARGET = 5000; // change this value, result is different constexpr int64_t ADD_VECTOR_LOOP = 5; constexpr milvus::IndexType INDEX_TYPE = milvus::IndexType::IVFSQ8; -constexpr int32_t N_LIST = 15000; +constexpr int32_t N_LIST = 16384; milvus::TableSchema BuildTableSchema() { diff --git a/core/src/sdk/examples/utils/Utils.cpp b/core/src/sdk/examples/utils/Utils.cpp index b45ebbea37..3d26dce77b 100644 --- a/core/src/sdk/examples/utils/Utils.cpp +++ b/core/src/sdk/examples/utils/Utils.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -194,7 +193,7 @@ Utils::CheckSearchResult(const std::vector if (result_id != search_id) { std::cout << "The top 1 result is wrong: " << result_id << " vs. " << search_id << std::endl; } else { - std::cout << "Check result sucessfully" << std::endl; + std::cout << "No." << i << " Check result successfully" << std::endl; } } BLOCK_SPLITER