提交 87b9405a 编写于 作者: H Heisenberg

Merge branch 'branch-0.5.0' into fix_thermal_bug


Former-commit-id: f44572457476b0a88e6e63ce3696b45ebcffd6fa
......@@ -28,6 +28,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-609 - Update task construct function
- MS-611 - Add resources validity check in ResourceMgr
- MS-619 - Add optimizer class in scheduler
- MS-614 - Preload table at startup
## New Feature
......
......@@ -18,6 +18,9 @@ db_config:
# sum of insert_buffer_size and cpu_cache_capacity cannot exceed total memory
build_index_gpu: 0 # gpu id used for building index
preload_table: # preload data at startup, '*' means load all tables, empty value means no preload
# you can specify preload tables like this: table1,table2,table3
metric_config:
enable_monitor: false # enable monitoring or not
collector: prometheus # prometheus
......
......@@ -104,7 +104,7 @@ ${LCOV_CMD} -r "${FILE_INFO_OUTPUT}" -o "${FILE_INFO_OUTPUT_NEW}" \
"src/metrics/MetricBase.h"\
"src/server/Server.cpp"\
"src/server/DBWrapper.cpp"\
"src/server/grpc_impl/GrpcMilvusServer.cpp"\
"src/server/grpc_impl/GrpcServer.cpp"\
"src/utils/easylogging++.h"\
"src/utils/easylogging++.cc"\
......
......@@ -36,7 +36,7 @@ struct BufferDeleter {
free((void*)buffer->data());
}
};
}
} // namespace internal
inline BufferPtr
MakeBufferSmart(uint8_t* data, const int64_t size) {
......
......@@ -15,12 +15,12 @@
// specific language governing permissions and limitations
// under the License.
#include <faiss/IndexIVF.h>
#include <faiss/index_io.h>
#include <utility>
#include "knowhere/common/Exception.h"
#include "knowhere/index/vector_index/FaissBaseIndex.h"
#include "knowhere/index/vector_index/IndexIVF.h"
#include "knowhere/index/vector_index/helpers/FaissIO.h"
namespace knowhere {
......
......@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
#include <faiss/IndexIVFPQ.h>
#include <faiss/gpu/GpuAutoTune.h>
#include <faiss/gpu/GpuIndexFlat.h>
#include <faiss/gpu/GpuIndexIVF.h>
......@@ -26,6 +25,7 @@
#include "knowhere/adapter/VectorAdapter.h"
#include "knowhere/common/Exception.h"
#include "knowhere/index/vector_index/IndexGPUIVF.h"
#include "knowhere/index/vector_index/IndexIVFPQ.h"
#include "knowhere/index/vector_index/helpers/Cloner.h"
#include "knowhere/index/vector_index/helpers/FaissIO.h"
......
......@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
#include <faiss/IndexIVFPQ.h>
#include <faiss/gpu/GpuAutoTune.h>
#include <faiss/gpu/GpuIndexIVFPQ.h>
#include <memory>
......@@ -23,6 +22,7 @@
#include "knowhere/adapter/VectorAdapter.h"
#include "knowhere/common/Exception.h"
#include "knowhere/index/vector_index/IndexGPUIVFPQ.h"
#include "knowhere/index/vector_index/IndexIVFPQ.h"
namespace knowhere {
......
......@@ -43,9 +43,9 @@ namespace kn = knowhere;
} // namespace
using ::testing::Combine;
using ::testing::TestWithParam;
using ::testing::Values;
using ::testing::Combine;
constexpr int device_id = 0;
constexpr int64_t DIM = 128;
......
......@@ -34,9 +34,9 @@ namespace kn = knowhere;
} // namespace
using ::testing::Combine;
using ::testing::TestWithParam;
using ::testing::Values;
using ::testing::Combine;
class KDTTest : public DataGen, public ::testing::Test {
protected:
......
......@@ -32,9 +32,9 @@ namespace kn = knowhere;
} // namespace
using ::testing::Combine;
using ::testing::TestWithParam;
using ::testing::Values;
using ::testing::Combine;
constexpr int64_t DEVICE_ID = 1;
......
......@@ -206,7 +206,7 @@ DBImpl::PreloadTable(const std::string& table_id) {
size += engine->PhysicalSize();
if (size > available_size) {
break;
return Status(SERVER_CACHE_FULL, "Cache is full");
} else {
try {
// step 1: load index
......@@ -639,8 +639,9 @@ DBImpl::MergeFiles(const std::string& table_id, const meta::DateT& date, const m
ENGINE_LOG_DEBUG << "Merging file " << file_schema.file_id_;
index_size = index->Size();
if (index_size >= file_schema.index_file_size_)
if (index_size >= file_schema.index_file_size_) {
break;
}
}
// step 3: serialize to disk
......
......@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
#include "HybridPass.h"
#include "scheduler/optimizer/HybridPass.h"
#include "scheduler/task/SearchTask.h"
namespace milvus {
......@@ -24,12 +24,12 @@ namespace scheduler {
bool
HybridPass::Run(const TaskPtr& task) {
// TODO: Index::IVFSQ8Hybrid, if nq < threshold set cpu, else set gpu
if (task->Type() != TaskType::SearchTask) return false;
if (task->Type() != TaskType::SearchTask)
return false;
auto search_task = std::static_pointer_cast<XSearchTask>(task);
// if (search_task->file_->engine_type_ == engine::EngineType::FAISS_IVFSQ8Hybrid)
return false;
}
}
}
} // namespace scheduler
} // namespace milvus
......@@ -16,16 +16,16 @@
// under the License.
#pragma once
#include <string>
#include <vector>
#include <condition_variable>
#include <deque>
#include <list>
#include <memory>
#include <mutex>
#include <queue>
#include <deque>
#include <unordered_map>
#include <string>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <memory>
#include <unordered_map>
#include <vector>
#include "Pass.h"
......@@ -43,6 +43,5 @@ class HybridPass : public Pass {
using HybridPassPtr = std::shared_ptr<HybridPass>;
}
}
} // namespace scheduler
} // namespace milvus
......@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
#include "Optimizer.h"
#include "scheduler/optimizer/Optimizer.h"
namespace milvus {
namespace scheduler {
......@@ -38,6 +38,5 @@ Optimizer::Run(const TaskPtr& task) {
return false;
}
}
}
} // namespace scheduler
} // namespace milvus
......@@ -16,16 +16,16 @@
// under the License.
#pragma once
#include <string>
#include <vector>
#include <condition_variable>
#include <deque>
#include <list>
#include <memory>
#include <mutex>
#include <queue>
#include <deque>
#include <unordered_map>
#include <string>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <memory>
#include <unordered_map>
#include <vector>
#include "Pass.h"
......@@ -40,12 +40,11 @@ class Optimizer {
Init();
bool
Run(const TaskPtr &task);
Run(const TaskPtr& task);
private:
std::vector<PassPtr> pass_list_;
};
}
}
} // namespace scheduler
} // namespace milvus
......@@ -16,16 +16,16 @@
// under the License.
#pragma once
#include <string>
#include <vector>
#include <condition_variable>
#include <deque>
#include <list>
#include <memory>
#include <mutex>
#include <queue>
#include <deque>
#include <unordered_map>
#include <string>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <memory>
#include <unordered_map>
#include <vector>
#include "scheduler/task/Task.h"
......@@ -35,12 +35,13 @@ namespace scheduler {
class Pass {
public:
virtual void
Init() {}
Init() {
}
virtual bool
Run(const TaskPtr& task) = 0;
};
using PassPtr = std::shared_ptr<Pass>;
}
}
} // namespace scheduler
} // namespace milvus
......@@ -20,12 +20,12 @@
#include <string>
/** \brief Milvus SDK namespace
*/
*/
namespace milvus {
/**
* @brief Status Code for SDK interface return
*/
* @brief Status Code for SDK interface return
*/
enum class StatusCode {
OK = 0,
......@@ -41,8 +41,8 @@ enum class StatusCode {
};
/**
* @brief Status for SDK interface return
*/
* @brief Status for SDK interface return
*/
class Status {
public:
Status(StatusCode code, const std::string& msg);
......
......@@ -655,294 +655,62 @@ Config::SetConfigValueInMem(const std::string& parent_key, const std::string& ch
}
////////////////////////////////////////////////////////////////////////////////
/* server config */
std::string
Config::GetServerConfigStrAddress() {
std::string value;
if (!GetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_ADDRESS, value).ok()) {
value = GetConfigNode(CONFIG_SERVER).GetValue(CONFIG_SERVER_ADDRESS, CONFIG_SERVER_ADDRESS_DEFAULT);
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_ADDRESS, value);
}
return value;
}
std::string
Config::GetServerConfigStrPort() {
std::string value;
if (!GetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_PORT, value).ok()) {
value = GetConfigNode(CONFIG_SERVER).GetValue(CONFIG_SERVER_PORT, CONFIG_SERVER_PORT_DEFAULT);
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_PORT, value);
}
return value;
}
std::string
Config::GetServerConfigStrDeployMode() {
std::string value;
if (!GetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_DEPLOY_MODE, value).ok()) {
value = GetConfigNode(CONFIG_SERVER).GetValue(CONFIG_SERVER_DEPLOY_MODE, CONFIG_SERVER_DEPLOY_MODE_DEFAULT);
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_DEPLOY_MODE, value);
}
return value;
}
std::string
Config::GetServerConfigStrTimeZone() {
std::string value;
if (!GetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_TIME_ZONE, value).ok()) {
value = GetConfigNode(CONFIG_SERVER).GetValue(CONFIG_SERVER_TIME_ZONE, CONFIG_SERVER_TIME_ZONE_DEFAULT);
SetConfigValueInMem(CONFIG_SERVER, CONFIG_SERVER_TIME_ZONE, value);
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
/* db config */
std::string
Config::GetDBConfigStrPrimaryPath() {
std::string value;
if (!GetConfigValueInMem(CONFIG_DB, CONFIG_DB_PRIMARY_PATH, value).ok()) {
value = GetConfigNode(CONFIG_DB).GetValue(CONFIG_DB_PRIMARY_PATH, CONFIG_DB_PRIMARY_PATH_DEFAULT);
SetConfigValueInMem(CONFIG_DB, CONFIG_DB_PRIMARY_PATH, value);
}
return value;
}
std::string
Config::GetDBConfigStrSecondaryPath() {
std::string value;
if (!GetConfigValueInMem(CONFIG_DB, CONFIG_DB_SECONDARY_PATH, value).ok()) {
value = GetConfigNode(CONFIG_DB).GetValue(CONFIG_DB_SECONDARY_PATH, CONFIG_DB_SECONDARY_PATH_DEFAULT);
SetConfigValueInMem(CONFIG_DB, CONFIG_DB_SECONDARY_PATH, value);
}
return value;
}
std::string
Config::GetDBConfigStrBackendUrl() {
std::string value;
if (!GetConfigValueInMem(CONFIG_DB, CONFIG_DB_BACKEND_URL, value).ok()) {
value = GetConfigNode(CONFIG_DB).GetValue(CONFIG_DB_BACKEND_URL, CONFIG_DB_BACKEND_URL_DEFAULT);
SetConfigValueInMem(CONFIG_DB, CONFIG_DB_BACKEND_URL, value);
}
return value;
}
std::string
Config::GetDBConfigStrArchiveDiskThreshold() {
std::string value;
if (!GetConfigValueInMem(CONFIG_DB, CONFIG_DB_ARCHIVE_DISK_THRESHOLD, value).ok()) {
value = GetConfigNode(CONFIG_DB).GetValue(CONFIG_DB_ARCHIVE_DISK_THRESHOLD,
CONFIG_DB_ARCHIVE_DISK_THRESHOLD_DEFAULT);
SetConfigValueInMem(CONFIG_DB, CONFIG_DB_ARCHIVE_DISK_THRESHOLD, value);
}
return value;
}
std::string
Config::GetDBConfigStrArchiveDaysThreshold() {
std::string value;
if (!GetConfigValueInMem(CONFIG_DB, CONFIG_DB_ARCHIVE_DAYS_THRESHOLD, value).ok()) {
value = GetConfigNode(CONFIG_DB).GetValue(CONFIG_DB_ARCHIVE_DAYS_THRESHOLD,
CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT);
SetConfigValueInMem(CONFIG_DB, CONFIG_DB_ARCHIVE_DAYS_THRESHOLD, value);
}
return value;
}
std::string
Config::GetDBConfigStrInsertBufferSize() {
std::string value;
if (!GetConfigValueInMem(CONFIG_DB, CONFIG_DB_INSERT_BUFFER_SIZE, value).ok()) {
value = GetConfigNode(CONFIG_DB).GetValue(CONFIG_DB_INSERT_BUFFER_SIZE, CONFIG_DB_INSERT_BUFFER_SIZE_DEFAULT);
SetConfigValueInMem(CONFIG_DB, CONFIG_DB_INSERT_BUFFER_SIZE, value);
}
return value;
}
std::string
Config::GetDBConfigStrBuildIndexGPU() {
std::string value;
if (!GetConfigValueInMem(CONFIG_DB, CONFIG_DB_BUILD_INDEX_GPU, value).ok()) {
value = GetConfigNode(CONFIG_DB).GetValue(CONFIG_DB_BUILD_INDEX_GPU, CONFIG_DB_BUILD_INDEX_GPU_DEFAULT);
SetConfigValueInMem(CONFIG_DB, CONFIG_DB_BUILD_INDEX_GPU, value);
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
/* metric config */
std::string
Config::GetMetricConfigStrEnableMonitor() {
Config::GetConfigStr(const std::string& parent_key, const std::string& child_key, const std::string& default_value) {
std::string value;
if (!GetConfigValueInMem(CONFIG_METRIC, CONFIG_METRIC_ENABLE_MONITOR, value).ok()) {
value =
GetConfigNode(CONFIG_METRIC).GetValue(CONFIG_METRIC_ENABLE_MONITOR, CONFIG_METRIC_ENABLE_MONITOR_DEFAULT);
SetConfigValueInMem(CONFIG_METRIC, CONFIG_METRIC_ENABLE_MONITOR, value);
if (!GetConfigValueInMem(parent_key, child_key, value).ok()) {
value = GetConfigNode(parent_key).GetValue(child_key, default_value);
SetConfigValueInMem(parent_key, child_key, value);
}
return value;
}
std::string
Config::GetMetricConfigStrCollector() {
std::string value;
if (!GetConfigValueInMem(CONFIG_METRIC, CONFIG_METRIC_COLLECTOR, value).ok()) {
value = GetConfigNode(CONFIG_METRIC).GetValue(CONFIG_METRIC_COLLECTOR, CONFIG_METRIC_COLLECTOR_DEFAULT);
SetConfigValueInMem(CONFIG_METRIC, CONFIG_METRIC_COLLECTOR, value);
}
return value;
}
std::string
Config::GetMetricConfigStrPrometheusPort() {
std::string value;
if (!GetConfigValueInMem(CONFIG_METRIC, CONFIG_METRIC_PROMETHEUS_PORT, value).ok()) {
value =
GetConfigNode(CONFIG_METRIC).GetValue(CONFIG_METRIC_PROMETHEUS_PORT, CONFIG_METRIC_PROMETHEUS_PORT_DEFAULT);
SetConfigValueInMem(CONFIG_METRIC, CONFIG_METRIC_PROMETHEUS_PORT, value);
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
/* cache config */
std::string
Config::GetCacheConfigStrCpuCacheCapacity() {
std::string value;
if (!GetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, value).ok()) {
value = GetConfigNode(CONFIG_CACHE)
.GetValue(CONFIG_CACHE_CPU_CACHE_CAPACITY, CONFIG_CACHE_CPU_CACHE_CAPACITY_DEFAULT);
SetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, value);
}
return value;
}
std::string
Config::GetCacheConfigStrCpuCacheThreshold() {
std::string value;
if (!GetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_THRESHOLD, value).ok()) {
value = GetConfigNode(CONFIG_CACHE)
.GetValue(CONFIG_CACHE_CPU_CACHE_THRESHOLD, CONFIG_CACHE_CPU_CACHE_THRESHOLD_DEFAULT);
SetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_THRESHOLD, value);
}
return value;
}
std::string
Config::GetCacheConfigStrGpuCacheCapacity() {
std::string value;
if (!GetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_GPU_CACHE_CAPACITY, value).ok()) {
value = GetConfigNode(CONFIG_CACHE)
.GetValue(CONFIG_CACHE_GPU_CACHE_CAPACITY, CONFIG_CACHE_GPU_CACHE_CAPACITY_DEFAULT);
SetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_GPU_CACHE_CAPACITY, value);
}
return value;
}
std::string
Config::GetCacheConfigStrGpuCacheThreshold() {
std::string value;
if (!GetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_GPU_CACHE_THRESHOLD, value).ok()) {
value = GetConfigNode(CONFIG_CACHE)
.GetValue(CONFIG_CACHE_GPU_CACHE_THRESHOLD, CONFIG_CACHE_GPU_CACHE_THRESHOLD_DEFAULT);
SetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_GPU_CACHE_THRESHOLD, value);
}
return value;
}
std::string
Config::GetCacheConfigStrCacheInsertData() {
std::string value;
if (!GetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CACHE_INSERT_DATA, value).ok()) {
value = GetConfigNode(CONFIG_CACHE)
.GetValue(CONFIG_CACHE_CACHE_INSERT_DATA, CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT);
SetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CACHE_INSERT_DATA, value);
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
/* engine config */
std::string
Config::GetEngineConfigStrUseBlasThreshold() {
std::string value;
if (!GetConfigValueInMem(CONFIG_ENGINE, CONFIG_ENGINE_USE_BLAS_THRESHOLD, value).ok()) {
value = GetConfigNode(CONFIG_ENGINE)
.GetValue(CONFIG_ENGINE_USE_BLAS_THRESHOLD, CONFIG_ENGINE_USE_BLAS_THRESHOLD_DEFAULT);
SetConfigValueInMem(CONFIG_ENGINE, CONFIG_ENGINE_USE_BLAS_THRESHOLD, value);
}
return value;
}
std::string
Config::GetEngineConfigStrOmpThreadNum() {
std::string value;
if (!GetConfigValueInMem(CONFIG_ENGINE, CONFIG_ENGINE_OMP_THREAD_NUM, value).ok()) {
value =
GetConfigNode(CONFIG_ENGINE).GetValue(CONFIG_ENGINE_OMP_THREAD_NUM, CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT);
SetConfigValueInMem(CONFIG_ENGINE, CONFIG_ENGINE_OMP_THREAD_NUM, value);
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
/* resource config */
std::string
Config::GetResourceConfigStrMode() {
std::string value;
if (!GetConfigValueInMem(CONFIG_RESOURCE, CONFIG_RESOURCE_MODE, value).ok()) {
value = GetConfigNode(CONFIG_RESOURCE).GetValue(CONFIG_RESOURCE_MODE, CONFIG_RESOURCE_MODE_DEFAULT);
SetConfigValueInMem(CONFIG_RESOURCE, CONFIG_RESOURCE_MODE, value);
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
Status
Config::GetServerConfigAddress(std::string& value) {
value = GetServerConfigStrAddress();
value = GetConfigStr(CONFIG_SERVER, CONFIG_SERVER_ADDRESS, CONFIG_SERVER_ADDRESS_DEFAULT);
return CheckServerConfigAddress(value);
}
Status
Config::GetServerConfigPort(std::string& value) {
value = GetServerConfigStrPort();
value = GetConfigStr(CONFIG_SERVER, CONFIG_SERVER_PORT, CONFIG_SERVER_PORT_DEFAULT);
return CheckServerConfigPort(value);
}
Status
Config::GetServerConfigDeployMode(std::string& value) {
value = GetServerConfigStrDeployMode();
value = GetConfigStr(CONFIG_SERVER, CONFIG_SERVER_DEPLOY_MODE, CONFIG_SERVER_DEPLOY_MODE_DEFAULT);
return CheckServerConfigDeployMode(value);
}
Status
Config::GetServerConfigTimeZone(std::string& value) {
value = GetServerConfigStrTimeZone();
value = GetConfigStr(CONFIG_SERVER, CONFIG_SERVER_TIME_ZONE, CONFIG_SERVER_TIME_ZONE_DEFAULT);
return CheckServerConfigTimeZone(value);
}
Status
Config::GetDBConfigPrimaryPath(std::string& value) {
value = GetDBConfigStrPrimaryPath();
value = GetConfigStr(CONFIG_DB, CONFIG_DB_PRIMARY_PATH, CONFIG_DB_PRIMARY_PATH_DEFAULT);
return CheckDBConfigPrimaryPath(value);
}
Status
Config::GetDBConfigSecondaryPath(std::string& value) {
value = GetDBConfigStrSecondaryPath();
value = GetConfigStr(CONFIG_DB, CONFIG_DB_SECONDARY_PATH, CONFIG_DB_SECONDARY_PATH_DEFAULT);
return Status::OK();
}
Status
Config::GetDBConfigBackendUrl(std::string& value) {
value = GetDBConfigStrBackendUrl();
value = GetConfigStr(CONFIG_DB, CONFIG_DB_BACKEND_URL, CONFIG_DB_BACKEND_URL_DEFAULT);
return CheckDBConfigBackendUrl(value);
}
Status
Config::GetDBConfigArchiveDiskThreshold(int32_t& value) {
std::string str = GetDBConfigStrArchiveDiskThreshold();
std::string str =
GetConfigStr(CONFIG_DB, CONFIG_DB_ARCHIVE_DISK_THRESHOLD, CONFIG_DB_ARCHIVE_DISK_THRESHOLD_DEFAULT);
Status s = CheckDBConfigArchiveDiskThreshold(str);
if (!s.ok()) {
return s;
......@@ -954,7 +722,8 @@ Config::GetDBConfigArchiveDiskThreshold(int32_t& value) {
Status
Config::GetDBConfigArchiveDaysThreshold(int32_t& value) {
std::string str = GetDBConfigStrArchiveDaysThreshold();
std::string str =
GetConfigStr(CONFIG_DB, CONFIG_DB_ARCHIVE_DAYS_THRESHOLD, CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT);
Status s = CheckDBConfigArchiveDaysThreshold(str);
if (!s.ok()) {
return s;
......@@ -966,7 +735,7 @@ Config::GetDBConfigArchiveDaysThreshold(int32_t& value) {
Status
Config::GetDBConfigInsertBufferSize(int32_t& value) {
std::string str = GetDBConfigStrInsertBufferSize();
std::string str = GetConfigStr(CONFIG_DB, CONFIG_DB_INSERT_BUFFER_SIZE, CONFIG_DB_INSERT_BUFFER_SIZE_DEFAULT);
Status s = CheckDBConfigInsertBufferSize(str);
if (!s.ok()) {
return s;
......@@ -978,7 +747,7 @@ Config::GetDBConfigInsertBufferSize(int32_t& value) {
Status
Config::GetDBConfigBuildIndexGPU(int32_t& value) {
std::string str = GetDBConfigStrBuildIndexGPU();
std::string str = GetConfigStr(CONFIG_DB, CONFIG_DB_BUILD_INDEX_GPU, CONFIG_DB_BUILD_INDEX_GPU_DEFAULT);
Status s = CheckDBConfigBuildIndexGPU(str);
if (!s.ok()) {
return s;
......@@ -988,9 +757,15 @@ Config::GetDBConfigBuildIndexGPU(int32_t& value) {
return Status::OK();
}
Status
Config::GetDBConfigPreloadTable(std::string& value) {
value = GetConfigStr(CONFIG_DB, CONFIG_DB_PRELOAD_TABLE);
return Status::OK();
}
Status
Config::GetMetricConfigEnableMonitor(bool& value) {
std::string str = GetMetricConfigStrEnableMonitor();
std::string str = GetConfigStr(CONFIG_METRIC, CONFIG_METRIC_ENABLE_MONITOR, CONFIG_METRIC_ENABLE_MONITOR_DEFAULT);
Status s = CheckMetricConfigEnableMonitor(str);
if (!s.ok()) {
return s;
......@@ -1003,19 +778,20 @@ Config::GetMetricConfigEnableMonitor(bool& value) {
Status
Config::GetMetricConfigCollector(std::string& value) {
value = GetMetricConfigStrCollector();
value = GetConfigStr(CONFIG_METRIC, CONFIG_METRIC_COLLECTOR, CONFIG_METRIC_COLLECTOR_DEFAULT);
return Status::OK();
}
Status
Config::GetMetricConfigPrometheusPort(std::string& value) {
value = GetMetricConfigStrPrometheusPort();
value = GetConfigStr(CONFIG_METRIC, CONFIG_METRIC_PROMETHEUS_PORT, CONFIG_METRIC_PROMETHEUS_PORT_DEFAULT);
return CheckMetricConfigPrometheusPort(value);
}
Status
Config::GetCacheConfigCpuCacheCapacity(int32_t& value) {
std::string str = GetCacheConfigStrCpuCacheCapacity();
std::string str =
GetConfigStr(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, CONFIG_CACHE_CPU_CACHE_CAPACITY_DEFAULT);
Status s = CheckCacheConfigCpuCacheCapacity(str);
if (!s.ok()) {
return s;
......@@ -1027,7 +803,8 @@ Config::GetCacheConfigCpuCacheCapacity(int32_t& value) {
Status
Config::GetCacheConfigCpuCacheThreshold(float& value) {
std::string str = GetCacheConfigStrCpuCacheThreshold();
std::string str =
GetConfigStr(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_THRESHOLD, CONFIG_CACHE_CPU_CACHE_THRESHOLD_DEFAULT);
Status s = CheckCacheConfigCpuCacheThreshold(str);
if (!s.ok()) {
return s;
......@@ -1039,7 +816,8 @@ Config::GetCacheConfigCpuCacheThreshold(float& value) {
Status
Config::GetCacheConfigGpuCacheCapacity(int32_t& value) {
std::string str = GetCacheConfigStrGpuCacheCapacity();
std::string str =
GetConfigStr(CONFIG_CACHE, CONFIG_CACHE_GPU_CACHE_CAPACITY, CONFIG_CACHE_GPU_CACHE_CAPACITY_DEFAULT);
Status s = CheckCacheConfigGpuCacheCapacity(str);
if (!s.ok()) {
return s;
......@@ -1051,7 +829,8 @@ Config::GetCacheConfigGpuCacheCapacity(int32_t& value) {
Status
Config::GetCacheConfigGpuCacheThreshold(float& value) {
std::string str = GetCacheConfigStrGpuCacheThreshold();
std::string str =
GetConfigStr(CONFIG_CACHE, CONFIG_CACHE_GPU_CACHE_THRESHOLD, CONFIG_CACHE_GPU_CACHE_THRESHOLD_DEFAULT);
Status s = CheckCacheConfigGpuCacheThreshold(str);
if (!s.ok()) {
return s;
......@@ -1063,7 +842,8 @@ Config::GetCacheConfigGpuCacheThreshold(float& value) {
Status
Config::GetCacheConfigCacheInsertData(bool& value) {
std::string str = GetCacheConfigStrCacheInsertData();
std::string str =
GetConfigStr(CONFIG_CACHE, CONFIG_CACHE_CACHE_INSERT_DATA, CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT);
Status s = CheckCacheConfigCacheInsertData(str);
if (!s.ok()) {
return s;
......@@ -1076,7 +856,8 @@ Config::GetCacheConfigCacheInsertData(bool& value) {
Status
Config::GetEngineConfigUseBlasThreshold(int32_t& value) {
std::string str = GetEngineConfigStrUseBlasThreshold();
std::string str =
GetConfigStr(CONFIG_ENGINE, CONFIG_ENGINE_USE_BLAS_THRESHOLD, CONFIG_ENGINE_USE_BLAS_THRESHOLD_DEFAULT);
Status s = CheckEngineConfigUseBlasThreshold(str);
if (!s.ok()) {
return s;
......@@ -1088,7 +869,7 @@ Config::GetEngineConfigUseBlasThreshold(int32_t& value) {
Status
Config::GetEngineConfigOmpThreadNum(int32_t& value) {
std::string str = GetEngineConfigStrOmpThreadNum();
std::string str = GetConfigStr(CONFIG_ENGINE, CONFIG_ENGINE_OMP_THREAD_NUM, CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT);
Status s = CheckEngineConfigOmpThreadNum(str);
if (!s.ok()) {
return s;
......@@ -1100,7 +881,7 @@ Config::GetEngineConfigOmpThreadNum(int32_t& value) {
Status
Config::GetResourceConfigMode(std::string& value) {
value = GetResourceConfigStrMode();
value = GetConfigStr(CONFIG_RESOURCE, CONFIG_RESOURCE_MODE, CONFIG_RESOURCE_MODE_DEFAULT);
return CheckResourceConfigMode(value);
}
......
......@@ -56,6 +56,7 @@ static const char* CONFIG_DB_INSERT_BUFFER_SIZE = "insert_buffer_size";
static const char* CONFIG_DB_INSERT_BUFFER_SIZE_DEFAULT = "4";
static const char* CONFIG_DB_BUILD_INDEX_GPU = "build_index_gpu";
static const char* CONFIG_DB_BUILD_INDEX_GPU_DEFAULT = "0";
static const char* CONFIG_DB_PRELOAD_TABLE = "preload_table";
/* cache config */
static const char* CONFIG_CACHE = "cache_config";
......@@ -178,62 +179,8 @@ class Config {
Status
CheckResourceConfigPool(const std::vector<std::string>& value);
///////////////////////////////////////////////////////////////////////////
/* server config */
std::string
GetServerConfigStrAddress();
std::string
GetServerConfigStrPort();
std::string
GetServerConfigStrDeployMode();
std::string
GetServerConfigStrTimeZone();
/* db config */
std::string
GetDBConfigStrPrimaryPath();
std::string
GetDBConfigStrSecondaryPath();
std::string
GetDBConfigStrBackendUrl();
std::string
GetDBConfigStrArchiveDiskThreshold();
std::string
GetDBConfigStrArchiveDaysThreshold();
std::string
GetDBConfigStrInsertBufferSize();
std::string
GetDBConfigStrBuildIndexGPU();
/* metric config */
std::string
GetMetricConfigStrEnableMonitor();
std::string
GetMetricConfigStrCollector();
std::string
GetMetricConfigStrPrometheusPort();
/* cache config */
std::string
GetCacheConfigStrCpuCacheCapacity();
std::string
GetCacheConfigStrCpuCacheThreshold();
std::string
GetCacheConfigStrGpuCacheCapacity();
std::string
GetCacheConfigStrGpuCacheThreshold();
std::string
GetCacheConfigStrCacheInsertData();
/* engine config */
std::string
GetEngineConfigStrUseBlasThreshold();
std::string
GetEngineConfigStrOmpThreadNum();
/* resource config */
std::string
GetResourceConfigStrMode();
GetConfigStr(const std::string& parent_key, const std::string& child_key, const std::string& default_value = "");
public:
/* server config */
......@@ -261,6 +208,8 @@ class Config {
GetDBConfigInsertBufferSize(int32_t& value);
Status
GetDBConfigBuildIndexGPU(int32_t& value);
Status
GetDBConfigPreloadTable(std::string& value);
/* metric config */
Status
......
......@@ -25,6 +25,7 @@
#include <faiss/utils.h>
#include <omp.h>
#include <string>
#include <vector>
namespace milvus {
namespace server {
......@@ -155,6 +156,20 @@ DBWrapper::StartService() {
db_->Start();
// preload table
std::string preload_tables;
s = config.GetDBConfigPreloadTable(preload_tables);
if (!s.ok()) {
return s;
}
s = PreloadTables(preload_tables);
if (!s.ok()) {
std::cerr << "ERROR! Failed to preload tables: " << preload_tables << std::endl;
std::cerr << s.ToString() << std::endl;
kill(0, SIGUSR1);
}
return Status::OK();
}
......@@ -167,5 +182,34 @@ DBWrapper::StopService() {
return Status::OK();
}
Status
DBWrapper::PreloadTables(const std::string& preload_tables) {
if (preload_tables.empty()) {
// do nothing
} else if (preload_tables == "*") {
// load all tables
std::vector<engine::meta::TableSchema> table_schema_array;
db_->AllTables(table_schema_array);
for (auto& schema : table_schema_array) {
auto status = db_->PreloadTable(schema.table_id_);
if (!status.ok()) {
return status;
}
}
} else {
std::vector<std::string> table_names;
StringHelpFunctions::SplitStringByDelimeter(preload_tables, ",", table_names);
for (auto& name : table_names) {
auto status = db_->PreloadTable(name);
if (!status.ok()) {
return status;
}
}
}
return Status::OK();
}
} // namespace server
} // namespace milvus
......@@ -21,6 +21,7 @@
#include "utils/Status.h"
#include <memory>
#include <string>
namespace milvus {
namespace server {
......@@ -52,6 +53,10 @@ class DBWrapper {
return db_;
}
private:
Status
PreloadTables(const std::string& preload_tables);
private:
engine::DBPtr db_;
};
......
......@@ -148,25 +148,25 @@ class GrpcRequestHandler final : public ::milvus::grpc::MilvusService::Service {
::milvus::grpc::TopKQueryResultList* response) override;
/**
* @brief Internal use query interface
*
* This method is used to query vector in specified files.
*
* @param context, add context for every RPC
* @param request:
* file_id_array, specified files id array, queried.
* query_record_array, all vector are going to be queried.
* query_range_array, optional ranges for conditional search. If not specified, search whole table
* topk, how many similarity vectors will be searched.
*
* @param writer, write query result array.
*
* @return status
*
* @param context
* @param request
* @param writer
*/
* @brief Internal use query interface
*
* This method is used to query vector in specified files.
*
* @param context, add context for every RPC
* @param request:
* file_id_array, specified files id array, queried.
* query_record_array, all vector are going to be queried.
* query_range_array, optional ranges for conditional search. If not specified, search whole table
* topk, how many similarity vectors will be searched.
*
* @param writer, write query result array.
*
* @return status
*
* @param context
* @param request
* @param writer
*/
::grpc::Status
SearchInFiles(::grpc::ServerContext* context, const ::milvus::grpc::SearchInFilesParam* request,
::milvus::grpc::TopKQueryResultList* response) override;
......
......@@ -36,7 +36,6 @@ ErrorMap(ErrorCode code) {
{SERVER_INVALID_ARGUMENT, ::milvus::grpc::ErrorCode::ILLEGAL_ARGUMENT},
{SERVER_FILE_NOT_FOUND, ::milvus::grpc::ErrorCode::FILE_NOT_FOUND},
{SERVER_NOT_IMPLEMENT, ::milvus::grpc::ErrorCode::UNEXPECTED_ERROR},
{SERVER_BLOCKING_QUEUE_EMPTY, ::milvus::grpc::ErrorCode::UNEXPECTED_ERROR},
{SERVER_CANNOT_CREATE_FOLDER, ::milvus::grpc::ErrorCode::CANNOT_CREATE_FOLDER},
{SERVER_CANNOT_CREATE_FILE, ::milvus::grpc::ErrorCode::CANNOT_CREATE_FILE},
{SERVER_CANNOT_DELETE_FOLDER, ::milvus::grpc::ErrorCode::CANNOT_DELETE_FOLDER},
......@@ -57,7 +56,7 @@ ErrorMap(ErrorCode code) {
{SERVER_INVALID_INDEX_FILE_SIZE, ::milvus::grpc::ErrorCode::ILLEGAL_ARGUMENT},
{SERVER_ILLEGAL_VECTOR_ID, ::milvus::grpc::ErrorCode::ILLEGAL_VECTOR_ID},
{SERVER_ILLEGAL_SEARCH_RESULT, ::milvus::grpc::ErrorCode::ILLEGAL_SEARCH_RESULT},
{SERVER_CACHE_ERROR, ::milvus::grpc::ErrorCode::CACHE_FAILED},
{SERVER_CACHE_FULL, ::milvus::grpc::ErrorCode::CACHE_FAILED},
{DB_META_TRANSACTION_FAILED, ::milvus::grpc::ErrorCode::META_FAILED},
{SERVER_BUILD_INDEX_ERROR, ::milvus::grpc::ErrorCode::BUILD_INDEX_ERROR},
{SERVER_OUT_OF_MEMORY, ::milvus::grpc::ErrorCode::OUT_OF_MEMORY},
......
......@@ -56,7 +56,6 @@ constexpr ErrorCode SERVER_NULL_POINTER = ToServerErrorCode(3);
constexpr ErrorCode SERVER_INVALID_ARGUMENT = ToServerErrorCode(4);
constexpr ErrorCode SERVER_FILE_NOT_FOUND = ToServerErrorCode(5);
constexpr ErrorCode SERVER_NOT_IMPLEMENT = ToServerErrorCode(6);
constexpr ErrorCode SERVER_BLOCKING_QUEUE_EMPTY = ToServerErrorCode(7);
constexpr ErrorCode SERVER_CANNOT_CREATE_FOLDER = ToServerErrorCode(8);
constexpr ErrorCode SERVER_CANNOT_CREATE_FILE = ToServerErrorCode(9);
constexpr ErrorCode SERVER_CANNOT_DELETE_FOLDER = ToServerErrorCode(10);
......@@ -74,7 +73,7 @@ constexpr ErrorCode SERVER_INVALID_ROWRECORD_ARRAY = ToServerErrorCode(107);
constexpr ErrorCode SERVER_INVALID_TOPK = ToServerErrorCode(108);
constexpr ErrorCode SERVER_ILLEGAL_VECTOR_ID = ToServerErrorCode(109);
constexpr ErrorCode SERVER_ILLEGAL_SEARCH_RESULT = ToServerErrorCode(110);
constexpr ErrorCode SERVER_CACHE_ERROR = ToServerErrorCode(111);
constexpr ErrorCode SERVER_CACHE_FULL = ToServerErrorCode(111);
constexpr ErrorCode SERVER_WRITE_ERROR = ToServerErrorCode(112);
constexpr ErrorCode SERVER_INVALID_NPROBE = ToServerErrorCode(113);
constexpr ErrorCode SERVER_INVALID_INDEX_NLIST = ToServerErrorCode(114);
......
......@@ -31,7 +31,7 @@ static int warning_idx = 0;
static int trace_idx = 0;
static int error_idx = 0;
static int fatal_idx = 0;
}
} // namespace
// TODO(yzb) : change the easylogging library to get the log level from parameter rather than filename
void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册