未验证 提交 504a9e30 编写于 作者: B BossZou 提交者: GitHub

Optimize config cpu_cache_capacity / gpu_cache_capacity setter (#1572) (#1629)

* add gpu cache config handler
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* remove cpu/gpu cache mgr from Config class by using cache config handler (fix #1572)
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* remove 0.8.0 from config version map
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* clean config header reference
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* fix bug in web readme
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* reduce gpu config handler to gpu resources handler
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* add engine config
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* modify handler hook(fix #1572)
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* update changlog
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* initalize value in handler by config default
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* code style format
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* fix compile error in release mode
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* resolve faiss blas threshold init in DBWrapper
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* modify cache header
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* remove comments
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* order headers
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* convert gpu res config to lower case
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* CI retry
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* adjust header order in cpu cache mar file
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* improve config test case
Signed-off-by: NYhz <yinghao.zou@zilliz.com>

* code format
Signed-off-by: NYhz <yinghao.zou@zilliz.com>
上级 616fd136
...@@ -20,6 +20,7 @@ Please mark all change in change log and use the issue from GitHub ...@@ -20,6 +20,7 @@ Please mark all change in change log and use the issue from GitHub
- \#1546 Move Config.cpp to config directory - \#1546 Move Config.cpp to config directory
- \#1547 Rename storage/file to storage/disk and rename classes - \#1547 Rename storage/file to storage/disk and rename classes
- \#1548 Move store/Directory to storage/Operation and add FSHandler - \#1548 Move store/Directory to storage/Operation and add FSHandler
- \#1572 optimize config cpu/gpu cache_capacity setter
- \#1619 Improve compact performance - \#1619 Improve compact performance
- \#1649 Fix Milvus crash on old CPU - \#1649 Fix Milvus crash on old CPU
- \#1653 IndexFlat (SSE) and IndexBinaryFlat performance improvement for small NQ - \#1653 IndexFlat (SSE) and IndexBinaryFlat performance improvement for small NQ
......
...@@ -331,7 +331,7 @@ endif () ...@@ -331,7 +331,7 @@ endif ()
if (DEFINED ENV{MILVUS_OATPP_URL}) if (DEFINED ENV{MILVUS_OATPP_URL})
set(MILVUS_OATPP_URL "$ENV{MILVUS_OATPP_URL}") set(MILVUS_OATPP_URL "$ENV{MILVUS_OATPP_URL}")
else () else ()
# set(OATPP_SOURCE_URL "https://github.com/oatpp/oatpp/archive/${OATPP_VERSION}.tar.gz") # set(OATPP_SOURCE_URL "https://github.com/oatpp/oatpp/archive/${OATPP_VERSION}.tar.gz")
set(OATPP_SOURCE_URL "https://github.com/BossZou/oatpp/archive/master.zip") set(OATPP_SOURCE_URL "https://github.com/BossZou/oatpp/archive/master.zip")
endif () endif ()
......
...@@ -10,12 +10,14 @@ ...@@ -10,12 +10,14 @@
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#include "cache/CpuCacheMgr.h" #include "cache/CpuCacheMgr.h"
#include "config/Config.h"
#include "utils/Log.h"
#include <fiu-local.h>
#include <utility> #include <utility>
#include <fiu-local.h>
#include "config/Config.h"
#include "utils/Log.h"
namespace milvus { namespace milvus {
namespace cache { namespace cache {
...@@ -35,6 +37,9 @@ CpuCacheMgr::CpuCacheMgr() { ...@@ -35,6 +37,9 @@ CpuCacheMgr::CpuCacheMgr() {
float cpu_cache_threshold; float cpu_cache_threshold;
config.GetCacheConfigCpuCacheThreshold(cpu_cache_threshold); config.GetCacheConfigCpuCacheThreshold(cpu_cache_threshold);
cache_->set_freemem_percent(cpu_cache_threshold); cache_->set_freemem_percent(cpu_cache_threshold);
SetIdentity("CpuCacheMgr");
AddCpuCacheCapacityListener();
} }
CpuCacheMgr* CpuCacheMgr*
...@@ -49,5 +54,10 @@ CpuCacheMgr::GetIndex(const std::string& key) { ...@@ -49,5 +54,10 @@ CpuCacheMgr::GetIndex(const std::string& key) {
return obj; return obj;
} }
void
CpuCacheMgr::OnCpuCacheCapacityChanged(int64_t value) {
SetCapacity(value * unit);
}
} // namespace cache } // namespace cache
} // namespace milvus } // namespace milvus
...@@ -11,16 +11,17 @@ ...@@ -11,16 +11,17 @@
#pragma once #pragma once
#include "CacheMgr.h"
#include "DataObj.h"
#include <memory> #include <memory>
#include <string> #include <string>
#include "cache/CacheMgr.h"
#include "cache/DataObj.h"
#include "config/handler/CacheConfigHandler.h"
namespace milvus { namespace milvus {
namespace cache { namespace cache {
class CpuCacheMgr : public CacheMgr<DataObjPtr> { class CpuCacheMgr : public CacheMgr<DataObjPtr>, public server::CacheConfigHandler {
private: private:
CpuCacheMgr(); CpuCacheMgr();
...@@ -31,6 +32,10 @@ class CpuCacheMgr : public CacheMgr<DataObjPtr> { ...@@ -31,6 +32,10 @@ class CpuCacheMgr : public CacheMgr<DataObjPtr> {
DataObjPtr DataObjPtr
GetIndex(const std::string& key); GetIndex(const std::string& key);
protected:
void
OnCpuCacheCapacityChanged(int64_t value) override;
}; };
} // namespace cache } // namespace cache
......
...@@ -32,15 +32,6 @@ GpuCacheMgr::GpuCacheMgr() { ...@@ -32,15 +32,6 @@ GpuCacheMgr::GpuCacheMgr() {
// All config values have been checked in Config::ValidateConfig() // All config values have been checked in Config::ValidateConfig()
server::Config& config = server::Config::GetInstance(); server::Config& config = server::Config::GetInstance();
config.GenUniqueIdentityID("GpuCacheMar", identity_);
config.GetGpuResourceConfigEnable(gpu_enable_);
server::ConfigCallBackF lambda = [this](const std::string& value) -> Status {
auto& config = server::Config::GetInstance();
return config.GetGpuResourceConfigEnable(this->gpu_enable_);
};
config.RegisterCallBack(server::CONFIG_GPU_RESOURCE, server::CONFIG_GPU_RESOURCE_ENABLE, identity_, lambda);
int64_t gpu_cache_cap; int64_t gpu_cache_cap;
config.GetGpuResourceConfigCacheCapacity(gpu_cache_cap); config.GetGpuResourceConfigCacheCapacity(gpu_cache_cap);
int64_t cap = gpu_cache_cap * G_BYTE; int64_t cap = gpu_cache_cap * G_BYTE;
...@@ -49,6 +40,10 @@ GpuCacheMgr::GpuCacheMgr() { ...@@ -49,6 +40,10 @@ GpuCacheMgr::GpuCacheMgr() {
float gpu_mem_threshold; float gpu_mem_threshold;
config.GetGpuResourceConfigCacheThreshold(gpu_mem_threshold); config.GetGpuResourceConfigCacheThreshold(gpu_mem_threshold);
cache_->set_freemem_percent(gpu_mem_threshold); cache_->set_freemem_percent(gpu_mem_threshold);
SetIdentity("GpuCacheMgr");
AddGpuEnableListener();
AddGpuCacheCapacityListener();
} }
GpuCacheMgr::~GpuCacheMgr() { GpuCacheMgr::~GpuCacheMgr() {
...@@ -83,6 +78,13 @@ GpuCacheMgr::InsertItem(const std::string& key, const milvus::cache::DataObjPtr& ...@@ -83,6 +78,13 @@ GpuCacheMgr::InsertItem(const std::string& key, const milvus::cache::DataObjPtr&
} }
} }
void
GpuCacheMgr::OnGpuCacheCapacityChanged(int64_t capacity) {
for (auto& iter : instance_) {
iter.second->SetCapacity(capacity * G_BYTE);
}
}
#endif #endif
} // namespace cache } // namespace cache
......
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#include "CacheMgr.h"
#include "DataObj.h"
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "cache/CacheMgr.h"
#include "cache/DataObj.h"
#include "config/handler/GpuResourceConfigHandler.h"
namespace milvus { namespace milvus {
namespace cache { namespace cache {
...@@ -23,7 +24,7 @@ namespace cache { ...@@ -23,7 +24,7 @@ namespace cache {
class GpuCacheMgr; class GpuCacheMgr;
using GpuCacheMgrPtr = std::shared_ptr<GpuCacheMgr>; using GpuCacheMgrPtr = std::shared_ptr<GpuCacheMgr>;
class GpuCacheMgr : public CacheMgr<DataObjPtr> { class GpuCacheMgr : public CacheMgr<DataObjPtr>, public server::GpuResourceConfigHandler {
public: public:
GpuCacheMgr(); GpuCacheMgr();
...@@ -38,6 +39,10 @@ class GpuCacheMgr : public CacheMgr<DataObjPtr> { ...@@ -38,6 +39,10 @@ class GpuCacheMgr : public CacheMgr<DataObjPtr> {
void void
InsertItem(const std::string& key, const DataObjPtr& data); InsertItem(const std::string& key, const DataObjPtr& data);
protected:
void
OnGpuCacheCapacityChanged(int64_t capacity) override;
private: private:
bool gpu_enable_ = true; bool gpu_enable_ = true;
std::string identity_; std::string identity_;
......
...@@ -9,14 +9,12 @@ ...@@ -9,14 +9,12 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#include <cache/CpuCacheMgr.h>
#include <cache/GpuCacheMgr.h>
#include <fiu-local.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <fstream>
#include <iostream> #include <iostream>
#include <regex> #include <regex>
#include <string> #include <string>
...@@ -25,11 +23,14 @@ ...@@ -25,11 +23,14 @@
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
#include <fiu-local.h>
#include "config/Config.h" #include "config/Config.h"
#include "config/YamlConfigMgr.h" #include "config/YamlConfigMgr.h"
#include "server/DBWrapper.h" #include "server/DBWrapper.h"
#include "thirdparty/nlohmann/json.hpp" #include "thirdparty/nlohmann/json.hpp"
#include "utils/CommonUtil.h" #include "utils/CommonUtil.h"
#include "utils/Log.h"
#include "utils/StringHelpFunctions.h" #include "utils/StringHelpFunctions.h"
#include "utils/ValidationUtil.h" #include "utils/ValidationUtil.h"
...@@ -562,6 +563,7 @@ Config::UpdateFileConfigFromMem(const std::string& parent_key, const std::string ...@@ -562,6 +563,7 @@ Config::UpdateFileConfigFromMem(const std::string& parent_key, const std::string
std::vector<std::string> vec; std::vector<std::string> vec;
StringHelpFunctions::SplitStringByDelimeter(value, ",", vec); StringHelpFunctions::SplitStringByDelimeter(value, ",", vec);
for (auto& s : vec) { for (auto& s : vec) {
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
value_str += "\n - " + s; value_str += "\n - " + s;
} }
} else { } else {
...@@ -1947,8 +1949,7 @@ Status ...@@ -1947,8 +1949,7 @@ Status
Config::SetCacheConfigCpuCacheCapacity(const std::string& value) { Config::SetCacheConfigCpuCacheCapacity(const std::string& value) {
CONFIG_CHECK(CheckCacheConfigCpuCacheCapacity(value)); CONFIG_CHECK(CheckCacheConfigCpuCacheCapacity(value));
CONFIG_CHECK(SetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, value)); CONFIG_CHECK(SetConfigValueInMem(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, value));
cache::CpuCacheMgr::GetInstance()->SetCapacity(std::stol(value) << 30); return ExecCallBacks(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, value);
return Status::OK();
} }
Status Status
...@@ -2046,14 +2047,7 @@ Status ...@@ -2046,14 +2047,7 @@ Status
Config::SetGpuResourceConfigCacheCapacity(const std::string& value) { Config::SetGpuResourceConfigCacheCapacity(const std::string& value) {
CONFIG_CHECK(CheckGpuResourceConfigCacheCapacity(value)); CONFIG_CHECK(CheckGpuResourceConfigCacheCapacity(value));
CONFIG_CHECK(SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_CAPACITY, value)); CONFIG_CHECK(SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_CAPACITY, value));
return ExecCallBacks(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_CAPACITY, value);
int64_t cap = std::stol(value);
std::vector<int64_t> gpus;
GetGpuResourceConfigSearchResources(gpus);
for (auto& gpu_id : gpus) {
cache::GpuCacheMgr::GetInstance(gpu_id)->SetCapacity(cap << 30);
}
return Status::OK();
} }
Status Status
......
...@@ -28,85 +28,68 @@ CacheConfigHandler::~CacheConfigHandler() { ...@@ -28,85 +28,68 @@ CacheConfigHandler::~CacheConfigHandler() {
RemoveCacheInsertDataListener(); RemoveCacheInsertDataListener();
} }
void //////////////////////////// Listener methods //////////////////////////////////
CacheConfigHandler::OnCpuCacheCapacityChanged(int64_t value) {
cpu_cache_capacity_ = value;
}
void
CacheConfigHandler::OnInsertBufferSizeChanged(int64_t value) {
insert_buffer_size_ = value;
}
void
CacheConfigHandler::OnCacheInsertDataChanged(bool value) {
cache_insert_data_ = value;
}
void void
CacheConfigHandler::AddCpuCacheCapacityListener() { CacheConfigHandler::AddCpuCacheCapacityListener() {
server::ConfigCallBackF lambda = [this](const std::string& value) -> Status { ConfigCallBackF lambda = [this](const std::string& value) -> Status {
server::Config& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
int64_t capacity; auto status = config.GetCacheConfigCpuCacheCapacity(cpu_cache_capacity_);
auto status = config.GetCacheConfigCpuCacheCapacity(capacity);
if (status.ok()) { if (status.ok()) {
OnCpuCacheCapacityChanged(capacity); OnCpuCacheCapacityChanged(cpu_cache_capacity_);
} }
return status; return status;
}; };
auto& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.RegisterCallBack(server::CONFIG_CACHE, server::CONFIG_CACHE_CPU_CACHE_CAPACITY, identity_, lambda); config.RegisterCallBack(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, identity_, lambda);
} }
void void
CacheConfigHandler::AddInsertBufferSizeListener() { CacheConfigHandler::AddInsertBufferSizeListener() {
server::ConfigCallBackF lambda = [this](const std::string& value) -> Status { ConfigCallBackF lambda = [this](const std::string& value) -> Status {
server::Config& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
int64_t size; auto status = config.GetCacheConfigInsertBufferSize(insert_buffer_size_);
auto status = config.GetCacheConfigInsertBufferSize(size);
if (status.ok()) { if (status.ok()) {
OnInsertBufferSizeChanged(size); OnInsertBufferSizeChanged(insert_buffer_size_);
} }
return status; return status;
}; };
auto& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.RegisterCallBack(server::CONFIG_CACHE, server::CONFIG_CACHE_INSERT_BUFFER_SIZE, identity_, lambda); config.RegisterCallBack(CONFIG_CACHE, CONFIG_CACHE_INSERT_BUFFER_SIZE, identity_, lambda);
} }
void void
CacheConfigHandler::AddCacheInsertDataListener() { CacheConfigHandler::AddCacheInsertDataListener() {
server::ConfigCallBackF lambda = [this](const std::string& value) -> Status { server::ConfigCallBackF lambda = [this](const std::string& value) -> Status {
auto& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
bool ok; auto status = config.GetCacheConfigCacheInsertData(cache_insert_data_);
auto status = config.GetCacheConfigCacheInsertData(ok);
if (status.ok()) { if (status.ok()) {
OnCacheInsertDataChanged(ok); OnCacheInsertDataChanged(cache_insert_data_);
} }
return status; return status;
}; };
auto& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.RegisterCallBack(server::CONFIG_CACHE, server::CONFIG_CACHE_CACHE_INSERT_DATA, identity_, lambda); config.RegisterCallBack(CONFIG_CACHE, CONFIG_CACHE_CACHE_INSERT_DATA, identity_, lambda);
} }
void void
CacheConfigHandler::RemoveCpuCacheCapacityListener() { CacheConfigHandler::RemoveCpuCacheCapacityListener() {
auto& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.CancelCallBack(server::CONFIG_CACHE, server::CONFIG_CACHE_CPU_CACHE_CAPACITY, identity_); config.CancelCallBack(CONFIG_CACHE, CONFIG_CACHE_CPU_CACHE_CAPACITY, identity_);
} }
void void
CacheConfigHandler::RemoveInsertBufferSizeListener() { CacheConfigHandler::RemoveInsertBufferSizeListener() {
auto& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.CancelCallBack(server::CONFIG_CACHE, server::CONFIG_CACHE_INSERT_BUFFER_SIZE, identity_); config.CancelCallBack(CONFIG_CACHE, CONFIG_CACHE_INSERT_BUFFER_SIZE, identity_);
} }
void void
CacheConfigHandler::RemoveCacheInsertDataListener() { CacheConfigHandler::RemoveCacheInsertDataListener() {
auto& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.CancelCallBack(server::CONFIG_CACHE, server::CONFIG_CACHE_CACHE_INSERT_DATA, identity_); config.CancelCallBack(server::CONFIG_CACHE, server::CONFIG_CACHE_CACHE_INSERT_DATA, identity_);
} }
} // namespace server } // namespace server
......
...@@ -20,17 +20,20 @@ namespace server { ...@@ -20,17 +20,20 @@ namespace server {
class CacheConfigHandler : virtual public ConfigHandler { class CacheConfigHandler : virtual public ConfigHandler {
public: public:
CacheConfigHandler(); CacheConfigHandler();
~CacheConfigHandler(); virtual ~CacheConfigHandler();
protected: protected:
virtual void virtual void
OnCpuCacheCapacityChanged(int64_t value); OnCpuCacheCapacityChanged(int64_t value) {
}
virtual void virtual void
OnInsertBufferSizeChanged(int64_t value); OnInsertBufferSizeChanged(int64_t value) {
}
virtual void virtual void
OnCacheInsertDataChanged(bool value); OnCacheInsertDataChanged(bool value) {
}
protected: protected:
void void
...@@ -52,8 +55,8 @@ class CacheConfigHandler : virtual public ConfigHandler { ...@@ -52,8 +55,8 @@ class CacheConfigHandler : virtual public ConfigHandler {
RemoveCacheInsertDataListener(); RemoveCacheInsertDataListener();
private: private:
int64_t cpu_cache_capacity_ = 4 /*GiB*/; int64_t cpu_cache_capacity_ = std::stoll(CONFIG_CACHE_CPU_CACHE_CAPACITY_DEFAULT) /*GiB*/;
int64_t insert_buffer_size_ = 1 /*GiB*/; int64_t insert_buffer_size_ = std::stoll(CONFIG_CACHE_INSERT_BUFFER_SIZE_DEFAULT) /*GiB*/;
bool cache_insert_data_ = false; bool cache_insert_data_ = false;
}; };
......
...@@ -20,6 +20,10 @@ namespace milvus { ...@@ -20,6 +20,10 @@ namespace milvus {
namespace server { namespace server {
class ConfigHandler { class ConfigHandler {
public:
ConfigHandler() = default;
virtual ~ConfigHandler() = default;
protected: protected:
void void
SetIdentity(const std::string& identity) { SetIdentity(const std::string& identity) {
......
// Copyright (C) 2019-2020 Zilliz. All rights reserved. // Copyright (C) 2019-2020 Zilliz. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
...@@ -9,50 +8,45 @@ ...@@ -9,50 +8,45 @@
// Unless required by applicable law or agreed to in writing, software distributed under the License // Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#ifdef MILVUS_GPU_VERSION
#include "config/handler/GpuConfigHandler.h" #include "config/handler/EngineConfigHandler.h"
#include <string>
namespace milvus { namespace milvus {
namespace server { namespace server {
GpuConfigHandler::GpuConfigHandler() { EngineConfigHandler::EngineConfigHandler() {
server::Config& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.GetGpuResourceConfigEnable(gpu_enable_); config.GetEngineConfigUseBlasThreshold(use_blas_threshold_);
}
GpuConfigHandler::~GpuConfigHandler() {
RemoveGpuEnableListener();
} }
////////////////////////////////////////////////////////////// EngineConfigHandler::~EngineConfigHandler() {
void RemoveUseBlasThresholdListener();
GpuConfigHandler::OnGpuEnableChanged(bool enable) {
gpu_enable_ = enable;
} }
//////////////////////////// Listener methods //////////////////////////////////
void void
GpuConfigHandler::AddGpuEnableListener() { EngineConfigHandler::AddUseBlasThresholdListener() {
auto& config = server::Config::GetInstance(); ConfigCallBackF lambda = [this](const std::string& value) -> Status {
server::ConfigCallBackF lambda = [this](const std::string& value) -> Status {
auto& config = server::Config::GetInstance(); auto& config = server::Config::GetInstance();
bool enable; auto status = config.GetEngineConfigUseBlasThreshold(use_blas_threshold_);
auto status = config.GetGpuResourceConfigEnable(enable);
if (status.ok()) { if (status.ok()) {
OnGpuEnableChanged(enable); OnUseBlasThresholdChanged(use_blas_threshold_);
} }
return status; return status;
}; };
config.RegisterCallBack(server::CONFIG_GPU_RESOURCE, server::CONFIG_GPU_RESOURCE_ENABLE, identity_, lambda);
auto& config = Config::GetInstance();
config.RegisterCallBack(CONFIG_ENGINE, CONFIG_ENGINE_USE_BLAS_THRESHOLD, identity_, lambda);
} }
void void
GpuConfigHandler::RemoveGpuEnableListener() { EngineConfigHandler::RemoveUseBlasThresholdListener() {
server::Config& config = server::Config::GetInstance(); auto& config = Config::GetInstance();
config.CancelCallBack(server::CONFIG_GPU_RESOURCE, server::CONFIG_GPU_RESOURCE_ENABLE, identity_); config.CancelCallBack(CONFIG_ENGINE, CONFIG_ENGINE_USE_BLAS_THRESHOLD, identity_);
} }
} // namespace server } // namespace server
} // namespace milvus } // namespace milvus
#endif
...@@ -8,12 +8,8 @@ ...@@ -8,12 +8,8 @@
// Unless required by applicable law or agreed to in writing, software distributed under the License // Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#ifdef MILVUS_GPU_VERSION
#pragma once
#include <exception> #pragma once
#include <limits>
#include <string>
#include "config/Config.h" #include "config/Config.h"
#include "config/handler/ConfigHandler.h" #include "config/handler/ConfigHandler.h"
...@@ -21,27 +17,28 @@ ...@@ -21,27 +17,28 @@
namespace milvus { namespace milvus {
namespace server { namespace server {
class GpuConfigHandler : virtual public ConfigHandler { class EngineConfigHandler : virtual public ConfigHandler {
public: public:
GpuConfigHandler(); EngineConfigHandler();
~GpuConfigHandler(); virtual ~EngineConfigHandler();
protected: protected:
virtual void virtual void
OnGpuEnableChanged(bool enable); OnUseBlasThresholdChanged(int64_t threshold) {
}
protected: protected:
void void
AddGpuEnableListener(); AddUseBlasThresholdListener();
protected:
void void
RemoveGpuEnableListener(); RemoveUseBlasThresholdListener();
protected: protected:
bool gpu_enable_ = true; int64_t use_blas_threshold_ = std::stoll(CONFIG_ENGINE_USE_BLAS_THRESHOLD_DEFAULT);
}; };
} // namespace server } // namespace server
} // namespace milvus } // namespace milvus
#endif
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#ifdef MILVUS_GPU_VERSION
#include "config/handler/GpuBuildConfigHandler.h"
#include <string>
#include <vector>
namespace milvus {
namespace server {
GpuBuildConfigHandler::GpuBuildConfigHandler() {
server::Config& config = server::Config::GetInstance();
config.GetGpuResourceConfigBuildIndexResources(build_gpus_);
}
GpuBuildConfigHandler::~GpuBuildConfigHandler() {
RemoveGpuBuildResListener();
}
////////////////////////////////////////////////////////////////
void
GpuBuildConfigHandler::OnGpuBuildResChanged(const std::vector<int64_t>& gpus) {
build_gpus_ = gpus;
}
void
GpuBuildConfigHandler::AddGpuBuildResListener() {
server::Config& config = server::Config::GetInstance();
server::ConfigCallBackF lambda = [this](const std::string& value) -> Status {
server::Config& config = server::Config::GetInstance();
std::vector<int64_t> gpu_ids;
auto status = config.GetGpuResourceConfigSearchResources(gpu_ids);
if (status.ok()) {
OnGpuBuildResChanged(gpu_ids);
}
return status;
};
config.RegisterCallBack(server::CONFIG_GPU_RESOURCE, server::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, identity_,
lambda);
}
void
GpuBuildConfigHandler::RemoveGpuBuildResListener() {
auto& config = server::Config::GetInstance();
config.CancelCallBack(server::CONFIG_GPU_RESOURCE, server::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, identity_);
}
} // namespace server
} // namespace milvus
#endif
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#ifdef MILVUS_GPU_VERSION
#pragma once
#include <vector>
#include "config/handler/GpuConfigHandler.h"
namespace milvus {
namespace server {
class GpuBuildConfigHandler : virtual public GpuConfigHandler {
public:
GpuBuildConfigHandler();
~GpuBuildConfigHandler();
public:
virtual void
OnGpuBuildResChanged(const std::vector<int64_t>& gpus);
protected:
void
AddGpuBuildResListener();
void
RemoveGpuBuildResListener();
protected:
std::vector<int64_t> build_gpus_;
};
} // namespace server
} // namespace milvus
#endif
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#ifdef MILVUS_GPU_VERSION
#include "config/handler/GpuResourceConfigHandler.h"
namespace milvus {
namespace server {
GpuResourceConfigHandler::GpuResourceConfigHandler() {
auto& config = Config::GetInstance();
config.GetGpuResourceConfigEnable(gpu_enable_);
}
GpuResourceConfigHandler::~GpuResourceConfigHandler() {
RemoveGpuEnableListener();
RemoveGpuCacheCapacityListener();
RemoveGpuBuildResourcesListener();
RemoveGpuSearchThresholdListener();
RemoveGpuSearchResourcesListener();
}
//////////////////////////// Listener methods //////////////////////////////////
void
GpuResourceConfigHandler::AddGpuEnableListener() {
auto& config = Config::GetInstance();
ConfigCallBackF lambda = [this](const std::string& value) -> Status {
auto& config = Config::GetInstance();
auto status = config.GetGpuResourceConfigEnable(gpu_enable_);
if (status.ok()) {
OnGpuEnableChanged(gpu_enable_);
}
return status;
};
config.RegisterCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE, identity_, lambda);
}
void
GpuResourceConfigHandler::AddGpuCacheCapacityListener() {
ConfigCallBackF lambda = [this](const std::string& value) -> Status {
if (!gpu_enable_) {
std::string msg =
std::string("GPU resources is disable. Cannot set config ") + CONFIG_GPU_RESOURCE_CACHE_CAPACITY;
return Status(SERVER_UNEXPECTED_ERROR, msg);
}
auto& config = Config::GetInstance();
auto status = config.GetGpuResourceConfigCacheCapacity(gpu_cache_capacity_);
if (status.ok()) {
OnGpuCacheCapacityChanged(gpu_cache_capacity_);
}
return status;
};
auto& config = Config::GetInstance();
config.RegisterCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_CAPACITY, identity_, lambda);
}
void
GpuResourceConfigHandler::AddGpuBuildResourcesListener() {
auto& config = Config::GetInstance();
ConfigCallBackF lambda = [this](const std::string& value) -> Status {
if (!gpu_enable_) {
std::string msg =
std::string("GPU resources is disable. Cannot set config ") + CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES;
return Status(SERVER_UNEXPECTED_ERROR, msg);
}
auto& config = Config::GetInstance();
auto status = config.GetGpuResourceConfigSearchResources(build_gpus_);
if (status.ok()) {
OnGpuBuildResChanged(build_gpus_);
}
return status;
};
config.RegisterCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, identity_, lambda);
}
void
GpuResourceConfigHandler::AddGpuSearchThresholdListener() {
auto& config = Config::GetInstance();
ConfigCallBackF lambda_gpu_threshold = [this](const std::string& value) -> Status {
if (!gpu_enable_) {
std::string msg =
std::string("GPU resources is disable. Cannot set config ") + CONFIG_ENGINE_GPU_SEARCH_THRESHOLD;
return Status(SERVER_UNEXPECTED_ERROR, msg);
}
auto& config = Config::GetInstance();
auto status = config.GetEngineConfigGpuSearchThreshold(threshold_);
if (status.ok()) {
OnGpuSearchThresholdChanged(threshold_);
}
return status;
};
config.RegisterCallBack(CONFIG_ENGINE, CONFIG_ENGINE_GPU_SEARCH_THRESHOLD, identity_, lambda_gpu_threshold);
}
void
GpuResourceConfigHandler::AddGpuSearchResourcesListener() {
auto& config = Config::GetInstance();
ConfigCallBackF lambda = [this](const std::string& value) -> Status {
if (!gpu_enable_) {
std::string msg =
std::string("GPU resources is disable. Cannot set config ") + CONFIG_GPU_RESOURCE_SEARCH_RESOURCES;
return Status(SERVER_UNEXPECTED_ERROR, msg);
}
auto& config = Config::GetInstance();
auto status = config.GetGpuResourceConfigSearchResources(search_gpus_);
if (status.ok()) {
OnGpuSearchResChanged(search_gpus_);
}
return status;
};
config.RegisterCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, identity_, lambda);
}
void
GpuResourceConfigHandler::RemoveGpuEnableListener() {
auto& config = Config::GetInstance();
config.CancelCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE, identity_);
}
void
GpuResourceConfigHandler::RemoveGpuCacheCapacityListener() {
auto& config = Config::GetInstance();
config.CancelCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_CAPACITY, identity_);
}
void
GpuResourceConfigHandler::RemoveGpuBuildResourcesListener() {
auto& config = Config::GetInstance();
config.CancelCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, identity_);
}
void
GpuResourceConfigHandler::RemoveGpuSearchThresholdListener() {
auto& config = Config::GetInstance();
config.CancelCallBack(CONFIG_ENGINE, CONFIG_ENGINE_GPU_SEARCH_THRESHOLD, identity_);
}
void
GpuResourceConfigHandler::RemoveGpuSearchResourcesListener() {
auto& config = Config::GetInstance();
config.CancelCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, identity_);
}
} // namespace server
} // namespace milvus
#endif
...@@ -11,42 +11,81 @@ ...@@ -11,42 +11,81 @@
#ifdef MILVUS_GPU_VERSION #ifdef MILVUS_GPU_VERSION
#pragma once #pragma once
#include <exception>
#include <limits> #include <limits>
#include <string>
#include <vector> #include <vector>
#include "config/handler/GpuConfigHandler.h" #include "config/Config.h"
#include "config/handler/ConfigHandler.h"
namespace milvus { namespace milvus {
namespace server { namespace server {
class GpuSearchConfigHandler : virtual public GpuConfigHandler { class GpuResourceConfigHandler : virtual public ConfigHandler {
public: public:
GpuSearchConfigHandler(); GpuResourceConfigHandler();
~GpuSearchConfigHandler(); virtual ~GpuResourceConfigHandler();
protected:
virtual void
OnGpuEnableChanged(bool enable) {
}
virtual void
OnGpuCacheCapacityChanged(int64_t capacity) {
}
public:
virtual void virtual void
OnGpuSearchThresholdChanged(int64_t threshold); OnGpuBuildResChanged(const std::vector<int64_t>& gpus) {
}
virtual void virtual void
OnGpuSearchResChanged(const std::vector<int64_t>& gpus); OnGpuSearchThresholdChanged(int64_t threshold) {
}
virtual void
OnGpuSearchResChanged(const std::vector<int64_t>& gpus) {
}
protected: protected:
void
AddGpuEnableListener();
void
AddGpuCacheCapacityListener();
void
AddGpuBuildResourcesListener();
void void
AddGpuSearchThresholdListener(); AddGpuSearchThresholdListener();
void void
AddGpuSearchResListener(); AddGpuSearchResourcesListener();
protected:
void
RemoveGpuEnableListener();
void
RemoveGpuCacheCapacityListener();
void
RemoveGpuBuildResourcesListener();
void void
RemoveGpuSearchThresholdListener(); RemoveGpuSearchThresholdListener();
void void
RemoveGpuSearchResListener(); RemoveGpuSearchResourcesListener();
protected: protected:
int64_t threshold_ = std::numeric_limits<int64_t>::max(); bool gpu_enable_ = true;
int64_t gpu_cache_capacity_ = std::stoll(CONFIG_GPU_RESOURCE_CACHE_CAPACITY_DEFAULT) /* GiB */;
int64_t threshold_ = std::stoll(CONFIG_ENGINE_USE_BLAS_THRESHOLD_DEFAULT);
std::vector<int64_t> build_gpus_;
std::vector<int64_t> search_gpus_; std::vector<int64_t> search_gpus_;
}; };
......
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#ifdef MILVUS_GPU_VERSION
#include <string>
#include <vector>
#include "config/Config.h"
#include "config/handler/GpuSearchConfigHandler.h"
namespace milvus {
namespace server {
GpuSearchConfigHandler::GpuSearchConfigHandler() {
server::Config& config = server::Config::GetInstance();
Status s = config.GetEngineConfigGpuSearchThreshold(threshold_);
if (!s.ok()) {
threshold_ = std::numeric_limits<int32_t>::max();
}
config.GetGpuResourceConfigSearchResources(search_gpus_);
}
GpuSearchConfigHandler::~GpuSearchConfigHandler() {
RemoveGpuSearchThresholdListener();
RemoveGpuSearchResListener();
}
////////////////////////////////////////////////////////////////////////
void
GpuSearchConfigHandler::OnGpuSearchThresholdChanged(int64_t threshold) {
threshold_ = threshold;
}
void
GpuSearchConfigHandler::OnGpuSearchResChanged(const std::vector<int64_t>& gpus) {
search_gpus_ = gpus;
}
void
GpuSearchConfigHandler::AddGpuSearchThresholdListener() {
server::Config& config = server::Config::GetInstance();
server::ConfigCallBackF lambda_gpu_threshold = [this](const std::string& value) -> Status {
server::Config& config = server::Config::GetInstance();
int64_t threshold;
auto status = config.GetEngineConfigGpuSearchThreshold(threshold);
if (status.ok()) {
OnGpuSearchThresholdChanged(threshold);
}
return status;
};
config.RegisterCallBack(server::CONFIG_ENGINE, server::CONFIG_ENGINE_GPU_SEARCH_THRESHOLD, identity_,
lambda_gpu_threshold);
}
void
GpuSearchConfigHandler::AddGpuSearchResListener() {
server::Config& config = server::Config::GetInstance();
server::ConfigCallBackF lambda_gpu_search_res = [this](const std::string& value) -> Status {
server::Config& config = server::Config::GetInstance();
std::vector<int64_t> gpu_ids;
auto status = config.GetGpuResourceConfigSearchResources(gpu_ids);
if (status.ok()) {
OnGpuSearchResChanged(gpu_ids);
}
return status;
};
config.RegisterCallBack(server::CONFIG_GPU_RESOURCE, server::CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, identity_,
lambda_gpu_search_res);
}
void
GpuSearchConfigHandler::RemoveGpuSearchThresholdListener() {
server::Config& config = server::Config::GetInstance();
config.CancelCallBack(server::CONFIG_ENGINE, server::CONFIG_ENGINE_GPU_SEARCH_THRESHOLD, identity_);
}
void
GpuSearchConfigHandler::RemoveGpuSearchResListener() {
auto& config = server::Config::GetInstance();
config.CancelCallBack(server::CONFIG_GPU_RESOURCE, server::CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, identity_);
}
} // namespace server
} // namespace milvus
#endif
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "cache/GpuCacheMgr.h" #include "cache/GpuCacheMgr.h"
#include "db/IDGenerator.h" #include "db/IDGenerator.h"
#include "engine/EngineFactory.h" #include "engine/EngineFactory.h"
#include "index/thirdparty/faiss/utils/distances.h"
#include "insert/MemMenagerFactory.h" #include "insert/MemMenagerFactory.h"
#include "meta/MetaConsts.h" #include "meta/MetaConsts.h"
#include "meta/MetaFactory.h" #include "meta/MetaFactory.h"
...@@ -77,12 +78,12 @@ DBImpl::DBImpl(const DBOptions& options) ...@@ -77,12 +78,12 @@ DBImpl::DBImpl(const DBOptions& options)
SetIdentity("DBImpl"); SetIdentity("DBImpl");
AddCacheInsertDataListener(); AddCacheInsertDataListener();
AddUseBlasThresholdListener();
Start(); Start();
} }
DBImpl::~DBImpl() { DBImpl::~DBImpl() {
RemoveCacheInsertDataListener();
Stop(); Stop();
} }
...@@ -2067,5 +2068,10 @@ DBImpl::OnCacheInsertDataChanged(bool value) { ...@@ -2067,5 +2068,10 @@ DBImpl::OnCacheInsertDataChanged(bool value) {
options_.insert_cache_immediately_ = value; options_.insert_cache_immediately_ = value;
} }
void
DBImpl::OnUseBlasThresholdChanged(int64_t threshold) {
faiss::distance_compute_blas_threshold = threshold;
}
} // namespace engine } // namespace engine
} // namespace milvus } // namespace milvus
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <vector> #include <vector>
#include "config/handler/CacheConfigHandler.h" #include "config/handler/CacheConfigHandler.h"
#include "config/handler/EngineConfigHandler.h"
#include "db/DB.h" #include "db/DB.h"
#include "db/IndexFailedChecker.h" #include "db/IndexFailedChecker.h"
#include "db/OngoingFileChecker.h" #include "db/OngoingFileChecker.h"
...@@ -38,7 +39,7 @@ namespace meta { ...@@ -38,7 +39,7 @@ namespace meta {
class Meta; class Meta;
} }
class DBImpl : public DB, public server::CacheConfigHandler { class DBImpl : public DB, public server::CacheConfigHandler, public server::EngineConfigHandler {
public: public:
explicit DBImpl(const DBOptions& options); explicit DBImpl(const DBOptions& options);
~DBImpl(); ~DBImpl();
...@@ -151,6 +152,9 @@ class DBImpl : public DB, public server::CacheConfigHandler { ...@@ -151,6 +152,9 @@ class DBImpl : public DB, public server::CacheConfigHandler {
void void
OnCacheInsertDataChanged(bool value) override; OnCacheInsertDataChanged(bool value) override;
void
OnUseBlasThresholdChanged(int64_t threshold) override;
private: private:
Status Status
QueryAsync(const std::shared_ptr<server::Context>& context, const std::string& table_id, QueryAsync(const std::shared_ptr<server::Context>& context, const std::string& table_id,
......
...@@ -11,19 +11,18 @@ ...@@ -11,19 +11,18 @@
#include "db/insert/MemTable.h" #include "db/insert/MemTable.h"
#include <cache/CpuCacheMgr.h>
#include <segment/SegmentReader.h>
#include <wrapper/VecIndex.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "cache/CpuCacheMgr.h"
#include "db/OngoingFileChecker.h" #include "db/OngoingFileChecker.h"
#include "db/Utils.h" #include "db/Utils.h"
#include "segment/SegmentReader.h"
#include "utils/Log.h" #include "utils/Log.h"
#include "wrapper/VecIndex.h"
namespace milvus { namespace milvus {
namespace engine { namespace engine {
......
...@@ -45,10 +45,6 @@ MemTableFile::MemTableFile(const std::string& table_id, const meta::MetaPtr& met ...@@ -45,10 +45,6 @@ MemTableFile::MemTableFile(const std::string& table_id, const meta::MetaPtr& met
AddCacheInsertDataListener(); AddCacheInsertDataListener();
} }
MemTableFile::~MemTableFile() {
RemoveCacheInsertDataListener();
}
Status Status
MemTableFile::CreateTableFile() { MemTableFile::CreateTableFile() {
meta::TableFileSchema table_file_schema; meta::TableFileSchema table_file_schema;
......
...@@ -30,7 +30,7 @@ class MemTableFile : public server::CacheConfigHandler { ...@@ -30,7 +30,7 @@ class MemTableFile : public server::CacheConfigHandler {
public: public:
MemTableFile(const std::string& table_id, const meta::MetaPtr& meta, const DBOptions& options); MemTableFile(const std::string& table_id, const meta::MetaPtr& meta, const DBOptions& options);
~MemTableFile(); ~MemTableFile() = default;
public: public:
Status Status
......
...@@ -24,10 +24,6 @@ BuildIndexJob::BuildIndexJob(engine::meta::MetaPtr meta_ptr, engine::DBOptions o ...@@ -24,10 +24,6 @@ BuildIndexJob::BuildIndexJob(engine::meta::MetaPtr meta_ptr, engine::DBOptions o
AddCacheInsertDataListener(); AddCacheInsertDataListener();
} }
BuildIndexJob::~BuildIndexJob() {
RemoveCacheInsertDataListener();
}
bool bool
BuildIndexJob::AddToIndexFiles(const engine::meta::TableFileSchemaPtr& to_index_file) { BuildIndexJob::AddToIndexFiles(const engine::meta::TableFileSchemaPtr& to_index_file) {
std::unique_lock<std::mutex> lock(mutex_); std::unique_lock<std::mutex> lock(mutex_);
......
...@@ -38,7 +38,7 @@ class BuildIndexJob : public Job, public server::CacheConfigHandler { ...@@ -38,7 +38,7 @@ class BuildIndexJob : public Job, public server::CacheConfigHandler {
public: public:
explicit BuildIndexJob(engine::meta::MetaPtr meta_ptr, engine::DBOptions options); explicit BuildIndexJob(engine::meta::MetaPtr meta_ptr, engine::DBOptions options);
~BuildIndexJob(); ~BuildIndexJob() = default;
public: public:
bool bool
......
...@@ -29,7 +29,7 @@ BuildIndexPass::Init() { ...@@ -29,7 +29,7 @@ BuildIndexPass::Init() {
SetIdentity("BuildIndexPass"); SetIdentity("BuildIndexPass");
AddGpuEnableListener(); AddGpuEnableListener();
AddGpuBuildResListener(); AddGpuBuildResourcesListener();
} }
bool bool
......
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "config/handler/GpuBuildConfigHandler.h" #include "config/handler/GpuResourceConfigHandler.h"
#include "scheduler/optimizer/Pass.h" #include "scheduler/optimizer/Pass.h"
namespace milvus { namespace milvus {
namespace scheduler { namespace scheduler {
class BuildIndexPass : public Pass, public server::GpuBuildConfigHandler { class BuildIndexPass : public Pass, public server::GpuResourceConfigHandler {
public: public:
BuildIndexPass() = default; BuildIndexPass() = default;
......
...@@ -37,7 +37,7 @@ FaissFlatPass::Init() { ...@@ -37,7 +37,7 @@ FaissFlatPass::Init() {
SetIdentity("FaissFlatPass"); SetIdentity("FaissFlatPass");
AddGpuEnableListener(); AddGpuEnableListener();
AddGpuSearchThresholdListener(); AddGpuSearchThresholdListener();
AddGpuSearchResListener(); AddGpuSearchResourcesListener();
} }
bool bool
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "config/handler/GpuSearchConfigHandler.h" #include "config/handler/GpuResourceConfigHandler.h"
#include "scheduler/optimizer/Pass.h" #include "scheduler/optimizer/Pass.h"
namespace milvus { namespace milvus {
namespace scheduler { namespace scheduler {
class FaissFlatPass : public Pass, public server::GpuSearchConfigHandler { class FaissFlatPass : public Pass, public server::GpuResourceConfigHandler {
public: public:
FaissFlatPass() = default; FaissFlatPass() = default;
......
...@@ -37,7 +37,7 @@ FaissIVFFlatPass::Init() { ...@@ -37,7 +37,7 @@ FaissIVFFlatPass::Init() {
SetIdentity("FaissIVFFlatPass"); SetIdentity("FaissIVFFlatPass");
AddGpuEnableListener(); AddGpuEnableListener();
AddGpuSearchThresholdListener(); AddGpuSearchThresholdListener();
AddGpuSearchResListener(); AddGpuSearchResourcesListener();
#endif #endif
} }
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "config/handler/GpuSearchConfigHandler.h" #include "config/handler/GpuResourceConfigHandler.h"
#include "scheduler/optimizer/Pass.h" #include "scheduler/optimizer/Pass.h"
namespace milvus { namespace milvus {
namespace scheduler { namespace scheduler {
class FaissIVFFlatPass : public Pass, public server::GpuSearchConfigHandler { class FaissIVFFlatPass : public Pass, public server::GpuResourceConfigHandler {
public: public:
FaissIVFFlatPass() = default; FaissIVFFlatPass() = default;
......
...@@ -39,7 +39,7 @@ FaissIVFPQPass::Init() { ...@@ -39,7 +39,7 @@ FaissIVFPQPass::Init() {
SetIdentity("FaissIVFPQPass"); SetIdentity("FaissIVFPQPass");
AddGpuEnableListener(); AddGpuEnableListener();
AddGpuSearchThresholdListener(); AddGpuSearchThresholdListener();
AddGpuSearchResListener(); AddGpuSearchResourcesListener();
#endif #endif
} }
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "config/handler/GpuSearchConfigHandler.h" #include "config/handler/GpuResourceConfigHandler.h"
#include "scheduler/optimizer/Pass.h" #include "scheduler/optimizer/Pass.h"
namespace milvus { namespace milvus {
namespace scheduler { namespace scheduler {
class FaissIVFPQPass : public Pass, public server::GpuSearchConfigHandler { class FaissIVFPQPass : public Pass, public server::GpuResourceConfigHandler {
public: public:
FaissIVFPQPass() = default; FaissIVFPQPass() = default;
......
...@@ -37,7 +37,7 @@ FaissIVFSQ8HPass::Init() { ...@@ -37,7 +37,7 @@ FaissIVFSQ8HPass::Init() {
SetIdentity("FaissIVFSQ8HPass"); SetIdentity("FaissIVFSQ8HPass");
AddGpuEnableListener(); AddGpuEnableListener();
AddGpuSearchThresholdListener(); AddGpuSearchThresholdListener();
AddGpuSearchResListener(); AddGpuSearchResourcesListener();
#endif #endif
} }
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "config/handler/GpuSearchConfigHandler.h" #include "config/handler/GpuResourceConfigHandler.h"
#include "scheduler/optimizer/Pass.h" #include "scheduler/optimizer/Pass.h"
namespace milvus { namespace milvus {
namespace scheduler { namespace scheduler {
class FaissIVFSQ8HPass : public Pass, public server::GpuSearchConfigHandler { class FaissIVFSQ8HPass : public Pass, public server::GpuResourceConfigHandler {
public: public:
FaissIVFSQ8HPass() = default; FaissIVFSQ8HPass() = default;
......
...@@ -37,7 +37,7 @@ FaissIVFSQ8Pass::Init() { ...@@ -37,7 +37,7 @@ FaissIVFSQ8Pass::Init() {
SetIdentity("FaissIVFSQ8Pass"); SetIdentity("FaissIVFSQ8Pass");
AddGpuEnableListener(); AddGpuEnableListener();
AddGpuSearchThresholdListener(); AddGpuSearchThresholdListener();
AddGpuSearchResListener(); AddGpuSearchResourcesListener();
#endif #endif
} }
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "config/handler/GpuSearchConfigHandler.h" #include "config/handler/GpuResourceConfigHandler.h"
#include "scheduler/optimizer/Pass.h" #include "scheduler/optimizer/Pass.h"
namespace milvus { namespace milvus {
namespace scheduler { namespace scheduler {
class FaissIVFSQ8Pass : public Pass, public server::GpuSearchConfigHandler { class FaissIVFSQ8Pass : public Pass, public server::GpuResourceConfigHandler {
public: public:
FaissIVFSQ8Pass() = default; FaissIVFSQ8Pass() = default;
......
...@@ -9,15 +9,17 @@ ...@@ -9,15 +9,17 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#include <faiss/utils/distances.h> #include "server/DBWrapper.h"
#include <omp.h> #include <omp.h>
#include <cmath> #include <cmath>
#include <string> #include <string>
#include <vector> #include <vector>
#include <faiss/utils/distances.h>
#include "config/Config.h" #include "config/Config.h"
#include "db/DBFactory.h" #include "db/DBFactory.h"
#include "server/DBWrapper.h"
#include "utils/CommonUtil.h" #include "utils/CommonUtil.h"
#include "utils/Log.h" #include "utils/Log.h"
#include "utils/StringHelpFunctions.h" #include "utils/StringHelpFunctions.h"
...@@ -145,19 +147,7 @@ DBWrapper::StartService() { ...@@ -145,19 +147,7 @@ DBWrapper::StartService() {
std::cerr << s.ToString() << std::endl; std::cerr << s.ToString() << std::endl;
return s; return s;
} }
faiss::distance_compute_blas_threshold = use_blas_threshold; faiss::distance_compute_blas_threshold = use_blas_threshold;
server::ConfigCallBackF lambda = [](const std::string& value) -> Status {
Config& config = Config::GetInstance();
int64_t blas_threshold;
auto status = config.GetEngineConfigUseBlasThreshold(blas_threshold);
if (status.ok()) {
faiss::distance_compute_blas_threshold = blas_threshold;
}
return status;
};
config.RegisterCallBack(server::CONFIG_ENGINE, server::CONFIG_ENGINE_USE_BLAS_THRESHOLD, "DBWrapper", lambda);
// set archive config // set archive config
engine::ArchiveConf::CriteriaT criterial; engine::ArchiveConf::CriteriaT criterial;
......
...@@ -1145,7 +1145,7 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments/15837 ...@@ -1145,7 +1145,7 @@ $ curl -X GET "http://127.0.0.1:19121/collections/test_collection/segments/15837
##### Request ##### Request
```shell ```shell
$ curl -X PUT "http://127.0.0.1:19121/collections/test_collection/vectors" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"search\":{\"topk\":2,\"vectors\":[[0.1]], \"params\":{\"nprobe\":16}}}" $ curl -X PUT "http://127.0.0.1:19121/collections/test_collection/vectors" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"search\":{\"topk\":2,\"vectors\":[[0.1]],\"params\":{\"nprobe\":16}}}"
``` ```
##### Response ##### Response
......
...@@ -1077,10 +1077,6 @@ WebRequestHandler::DropIndex(const OString& collection_name) { ...@@ -1077,10 +1077,6 @@ WebRequestHandler::DropIndex(const OString& collection_name) {
ASSIGN_RETURN_STATUS_DTO(status) ASSIGN_RETURN_STATUS_DTO(status)
} }
/***********
*
* Partition {
*/
StatusDto::ObjectWrapper StatusDto::ObjectWrapper
WebRequestHandler::CreatePartition(const OString& collection_name, const PartitionRequestDto::ObjectWrapper& param) { WebRequestHandler::CreatePartition(const OString& collection_name, const PartitionRequestDto::ObjectWrapper& param) {
if (nullptr == param->partition_tag.get()) { if (nullptr == param->partition_tag.get()) {
......
...@@ -172,10 +172,6 @@ class WebRequestHandler { ...@@ -172,10 +172,6 @@ class WebRequestHandler {
SetGpuConfig(const GPUConfigDto::ObjectWrapper& gpu_config_dto); SetGpuConfig(const GPUConfigDto::ObjectWrapper& gpu_config_dto);
#endif #endif
/**********
*
* Table
*/
StatusDto::ObjectWrapper StatusDto::ObjectWrapper
CreateTable(const TableRequestDto::ObjectWrapper& table_schema); CreateTable(const TableRequestDto::ObjectWrapper& table_schema);
StatusDto::ObjectWrapper StatusDto::ObjectWrapper
...@@ -187,10 +183,6 @@ class WebRequestHandler { ...@@ -187,10 +183,6 @@ class WebRequestHandler {
StatusDto::ObjectWrapper StatusDto::ObjectWrapper
DropTable(const OString& table_name); DropTable(const OString& table_name);
/**********
*
* Index
*/
StatusDto::ObjectWrapper StatusDto::ObjectWrapper
CreateIndex(const OString& table_name, const OString& body); CreateIndex(const OString& table_name, const OString& body);
...@@ -200,10 +192,6 @@ class WebRequestHandler { ...@@ -200,10 +192,6 @@ class WebRequestHandler {
StatusDto::ObjectWrapper StatusDto::ObjectWrapper
DropIndex(const OString& table_name); DropIndex(const OString& table_name);
/***********
*
* Partition
*/
StatusDto::ObjectWrapper StatusDto::ObjectWrapper
CreatePartition(const OString& table_name, const PartitionRequestDto::ObjectWrapper& param); CreatePartition(const OString& table_name, const PartitionRequestDto::ObjectWrapper& param);
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#include <cmath>
#include <limits> #include <limits>
#include <fiu-control.h> #include <fiu-control.h>
#include <fiu-local.h> #include <fiu-local.h>
#include <gtest/gtest-death-test.h> #include <gtest/gtest-death-test.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <cmath>
#include "config/Config.h" #include "config/Config.h"
#include "config/YamlConfigMgr.h" #include "config/YamlConfigMgr.h"
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "utils/StringHelpFunctions.h" #include "utils/StringHelpFunctions.h"
#include "utils/ValidationUtil.h" #include "utils/ValidationUtil.h"
namespace { namespace {
static constexpr uint64_t KB = 1024; static constexpr uint64_t KB = 1024;
...@@ -200,6 +199,16 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) { ...@@ -200,6 +199,16 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
ASSERT_TRUE(config.GetStorageConfigSecondaryPath(str_val).ok()); ASSERT_TRUE(config.GetStorageConfigSecondaryPath(str_val).ok());
ASSERT_TRUE(str_val == storage_secondary_path); ASSERT_TRUE(str_val == storage_secondary_path);
storage_secondary_path = "/home/zilliz,/tmp/milvus";
ASSERT_TRUE(config.SetStorageConfigSecondaryPath(storage_secondary_path).ok());
ASSERT_TRUE(config.GetStorageConfigSecondaryPath(str_val).ok());
ASSERT_TRUE(str_val == storage_secondary_path);
storage_secondary_path = "";
ASSERT_TRUE(config.SetStorageConfigSecondaryPath(storage_secondary_path).ok());
ASSERT_TRUE(config.GetStorageConfigSecondaryPath(str_val).ok());
ASSERT_TRUE(str_val == storage_secondary_path);
bool storage_s3_enable = true; bool storage_s3_enable = true;
ASSERT_TRUE(config.SetStorageConfigS3Enable(std::to_string(storage_s3_enable)).ok()); ASSERT_TRUE(config.SetStorageConfigS3Enable(std::to_string(storage_s3_enable)).ok());
ASSERT_TRUE(config.GetStorageConfigS3Enable(bool_val).ok()); ASSERT_TRUE(config.GetStorageConfigS3Enable(bool_val).ok());
...@@ -582,8 +591,13 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) { ...@@ -582,8 +591,13 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) {
/* storage config */ /* storage config */
ASSERT_FALSE(config.SetStorageConfigPrimaryPath("").ok()); ASSERT_FALSE(config.SetStorageConfigPrimaryPath("").ok());
ASSERT_FALSE(config.SetStorageConfigPrimaryPath("./milvus").ok());
ASSERT_FALSE(config.SetStorageConfigPrimaryPath("../milvus").ok());
ASSERT_FALSE(config.SetStorageConfigPrimaryPath("/**milvus").ok());
ASSERT_FALSE(config.SetStorageConfigPrimaryPath("/milvus--/path").ok());
// ASSERT_FALSE(config.SetStorageConfigSecondaryPath("").ok()); ASSERT_FALSE(config.SetStorageConfigSecondaryPath("../milvus,./zilliz").ok());
ASSERT_FALSE(config.SetStorageConfigSecondaryPath("/home/^^__^^,/zilliz").ok());
ASSERT_FALSE(config.SetStorageConfigS3Enable("10").ok()); ASSERT_FALSE(config.SetStorageConfigS3Enable("10").ok());
...@@ -1116,58 +1130,84 @@ TEST_F(ConfigTest, SERVER_CONFIG_OTHER_CONFIGS_FAIL_TEST) { ...@@ -1116,58 +1130,84 @@ TEST_F(ConfigTest, SERVER_CONFIG_OTHER_CONFIGS_FAIL_TEST) {
TEST_F(ConfigTest, SERVER_CONFIG_UPDATE_TEST) { TEST_F(ConfigTest, SERVER_CONFIG_UPDATE_TEST) {
std::string conf_file = std::string(CONFIG_PATH) + VALID_CONFIG_FILE; std::string conf_file = std::string(CONFIG_PATH) + VALID_CONFIG_FILE;
std::string yaml_value;
std::string reply_set, reply_get;
std::string cmd_set, cmd_get;
auto lambda = [&conf_file](const std::string& key, const std::string& child_key,
const std::string& default_value, std::string& value) {
auto * ymgr = milvus::server::YamlConfigMgr::GetInstance();
auto status = ymgr->LoadConfigFile(conf_file);
if (status.ok())
value = ymgr->GetRootNode().GetChild(key).GetValue(child_key, default_value);
return status;
};
milvus::server::Config& config = milvus::server::Config::GetInstance(); milvus::server::Config& config = milvus::server::Config::GetInstance();
auto status = config.LoadConfigFile(conf_file); auto status = config.LoadConfigFile(conf_file);
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_TRUE(status.ok()) << status.message();
// validate if setting config store in files /* validate if setting config store in files */
status = config.SetCacheConfigInsertBufferSize("2");
ASSERT_TRUE(status.ok()) << status.message();
// test numeric config value // test numeric config value
status = config.LoadConfigFile(conf_file); cmd_set = gen_set_command(ms::CONFIG_CACHE, ms::CONFIG_CACHE_INSERT_BUFFER_SIZE, "2");
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
int64_t value;
status = config.GetCacheConfigInsertBufferSize(value);
ASSERT_TRUE(status.ok()) << status.message();
ASSERT_EQ(value, 2);
// test boolean config value ASSERT_TRUE(lambda(ms::CONFIG_CACHE, ms::CONFIG_CACHE_INSERT_BUFFER_SIZE,
status = config.SetMetricConfigEnableMonitor("True"); ms::CONFIG_CACHE_INSERT_BUFFER_SIZE_DEFAULT, yaml_value).ok());
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_EQ("2", yaml_value);
status = config.LoadConfigFile(conf_file); // test boolean config value
ASSERT_TRUE(status.ok()) << status.message(); cmd_set = gen_set_command(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR, "True");
bool enable; ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
status = config.GetMetricConfigEnableMonitor(enable); ASSERT_TRUE(lambda(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR,
ASSERT_TRUE(status.ok()) << status.message(); ms::CONFIG_METRIC_ENABLE_MONITOR_DEFAULT, yaml_value).ok());
ASSERT_EQ(true, enable); ASSERT_EQ("true", yaml_value);
// invalid path cmd_set = gen_set_command(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR, "On");
status = config.SetStorageConfigPrimaryPath("/a--/a"); ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
ASSERT_FALSE(status.ok()); ASSERT_TRUE(lambda(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR,
ms::CONFIG_METRIC_ENABLE_MONITOR_DEFAULT, yaml_value).ok());
ASSERT_EQ("true", yaml_value);
cmd_set = gen_set_command(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR, "False");
ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
ASSERT_TRUE(lambda(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR,
ms::CONFIG_METRIC_ENABLE_MONITOR_DEFAULT, yaml_value).ok());
ASSERT_EQ("false", yaml_value);
cmd_set = gen_set_command(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR, "Off");
ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
ASSERT_TRUE(lambda(ms::CONFIG_METRIC, ms::CONFIG_METRIC_ENABLE_MONITOR,
ms::CONFIG_METRIC_ENABLE_MONITOR_DEFAULT, yaml_value).ok());
ASSERT_EQ("false", yaml_value);
// test path // test path
status = config.SetStorageConfigPrimaryPath("/tmp/milvus_config_unittest"); cmd_set = gen_set_command(ms::CONFIG_STORAGE, ms::CONFIG_STORAGE_PRIMARY_PATH, "/tmp/milvus_config_unittest");
ASSERT_TRUE(status.ok()); ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
ASSERT_TRUE(lambda(ms::CONFIG_STORAGE, ms::CONFIG_STORAGE_PRIMARY_PATH,
std::string path_value; ms::CONFIG_STORAGE_PRIMARY_PATH_DEFAULT, yaml_value).ok());
status = config.GetStorageConfigPrimaryPath(path_value); ASSERT_EQ("/tmp/milvus_config_unittest", yaml_value);
ASSERT_TRUE(status.ok());
ASSERT_EQ(path_value, "/tmp/milvus_config_unittest"); cmd_set = gen_set_command(ms::CONFIG_STORAGE, ms::CONFIG_STORAGE_SECONDARY_PATH, "/home/zilliz,/home/milvus");
ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
ASSERT_TRUE(lambda(ms::CONFIG_STORAGE, ms::CONFIG_STORAGE_SECONDARY_PATH,
ms::CONFIG_STORAGE_SECONDARY_PATH_DEFAULT, yaml_value).ok());
ASSERT_EQ("/home/zilliz,/home/milvus", yaml_value);
#ifdef MILVUS_GPU_VERSION #ifdef MILVUS_GPU_VERSION
status = config.SetGpuResourceConfigBuildIndexResources("gpu0"); cmd_set = gen_set_command(ms::CONFIG_GPU_RESOURCE, ms::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, "gpu0");
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
ASSERT_TRUE(lambda(ms::CONFIG_GPU_RESOURCE, ms::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES,
status = config.LoadConfigFile(conf_file); ms::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES_DEFAULT, yaml_value).ok());
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_EQ("gpu0", yaml_value);
std::vector<int64_t> gpus;
status = config.GetGpuResourceConfigBuildIndexResources(gpus); cmd_set = gen_set_command(ms::CONFIG_GPU_RESOURCE, ms::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, "GPU0");
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_TRUE(config.ProcessConfigCli(reply_set, cmd_set).ok());
ASSERT_EQ(1, gpus.size()); ASSERT_TRUE(lambda(ms::CONFIG_GPU_RESOURCE, ms::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES,
ASSERT_EQ(0, gpus[0]); ms::CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES_DEFAULT, yaml_value).ok());
ASSERT_EQ(value, 2); ASSERT_EQ("gpu0", yaml_value);
#endif #endif
} }
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "server/delivery/RequestScheduler.h" #include "server/delivery/RequestScheduler.h"
#include "server/delivery/request/BaseRequest.h" #include "server/delivery/request/BaseRequest.h"
#include "server/Server.h" #include "server/Server.h"
#include "src/version.h"
#include "server/web_impl/Types.h" #include "server/web_impl/Types.h"
#include "server/web_impl/WebServer.h" #include "server/web_impl/WebServer.h"
#include "server/web_impl/component/AppComponent.hpp" #include "server/web_impl/component/AppComponent.hpp"
...@@ -638,43 +637,53 @@ class TestClient : public oatpp::web::client::ApiClient { ...@@ -638,43 +637,53 @@ class TestClient : public oatpp::web::client::ApiClient {
API_CALL("GET", "/collections", showTables, QUERY(String, offset), QUERY(String, page_size)) API_CALL("GET", "/collections", showTables, QUERY(String, offset), QUERY(String, page_size))
API_CALL("OPTIONS", "/collections/{collection_name}", optionsTable, PATH(String, collection_name, "collection_name")) API_CALL("OPTIONS", "/collections/{collection_name}", optionsTable,
PATH(String, collection_name, "collection_name"))
API_CALL("GET", "/collections/{collection_name}", getTable, PATH(String, collection_name, "collection_name"), QUERY(String, info)) API_CALL("GET", "/collections/{collection_name}", getTable,
PATH(String, collection_name, "collection_name"), QUERY(String, info))
API_CALL("DELETE", "/collections/{collection_name}", dropTable, PATH(String, collection_name, "collection_name")) API_CALL("DELETE", "/collections/{collection_name}", dropTable, PATH(String, collection_name, "collection_name"))
API_CALL("OPTIONS", "/collections/{collection_name}/indexes", optionsIndexes, PATH(String, collection_name, "collection_name")) API_CALL("OPTIONS", "/collections/{collection_name}/indexes", optionsIndexes,
PATH(String, collection_name, "collection_name"))
API_CALL("POST", "/collections/{collection_name}/indexes", createIndex, PATH(String, collection_name, "collection_name"), API_CALL("POST", "/collections/{collection_name}/indexes", createIndex,
BODY_STRING(OString, body)) PATH(String, collection_name, "collection_name"), BODY_STRING(OString, body))
API_CALL("GET", "/collections/{collection_name}/indexes", getIndex, PATH(String, collection_name, "collection_name")) API_CALL("GET", "/collections/{collection_name}/indexes", getIndex,
PATH(String, collection_name, "collection_name"))
API_CALL("DELETE", "/collections/{collection_name}/indexes", dropIndex, PATH(String, collection_name, "collection_name")) API_CALL("DELETE", "/collections/{collection_name}/indexes", dropIndex,
PATH(String, collection_name, "collection_name"))
API_CALL("OPTIONS", "/collections/{collection_name}/partitions", optionsPartitions, PATH(String, collection_name, "collection_name")) API_CALL("OPTIONS", "/collections/{collection_name}/partitions", optionsPartitions,
PATH(String, collection_name, "collection_name"))
API_CALL("POST", "/collections/{collection_name}/partitions", createPartition, PATH(String, collection_name, "collection_name"), API_CALL("POST", "/collections/{collection_name}/partitions", createPartition,
PATH(String, collection_name, "collection_name"),
BODY_DTO(milvus::server::web::PartitionRequestDto::ObjectWrapper, body)) BODY_DTO(milvus::server::web::PartitionRequestDto::ObjectWrapper, body))
API_CALL("GET", "/collections/{collection_name}/partitions", showPartitions, PATH(String, collection_name, "collection_name"), API_CALL("GET", "/collections/{collection_name}/partitions", showPartitions,
PATH(String, collection_name, "collection_name"),
QUERY(String, offset), QUERY(String, page_size)) QUERY(String, offset), QUERY(String, page_size))
API_CALL("DELETE", "/collections/{collection_name}/partitions", dropPartition, API_CALL("DELETE", "/collections/{collection_name}/partitions", dropPartition,
PATH(String, collection_name, "collection_name"), BODY_STRING(String, body)) PATH(String, collection_name, "collection_name"), BODY_STRING(String, body))
API_CALL("GET", "/collections/{collection_name}/segments", showSegments, PATH(String, collection_name, "collection_name"), API_CALL("GET", "/collections/{collection_name}/segments", showSegments,
QUERY(String, offset), QUERY(String, page_size), QUERY(String, partition_tag)) PATH(String, collection_name, "collection_name"),
QUERY(String, offset), QUERY(String, page_size), QUERY(String, partition_tag))
API_CALL("GET", "/collections/{collection_name}/segments/{segment_name}/{info}", getSegmentInfo, API_CALL("GET", "/collections/{collection_name}/segments/{segment_name}/{info}", getSegmentInfo,
PATH(String, collection_name, "collection_name"), PATH(String, segment_name, "segment_name"), PATH(String, collection_name, "collection_name"), PATH(String, segment_name, "segment_name"),
PATH(String, info, "info"), QUERY(String, offset), QUERY(String, page_size)) PATH(String, info, "info"), QUERY(String, offset), QUERY(String, page_size))
API_CALL("OPTIONS", "/collections/{collection_name}/vectors", optionsVectors, PATH(String, collection_name, "collection_name")) API_CALL("OPTIONS", "/collections/{collection_name}/vectors", optionsVectors,
PATH(String, collection_name, "collection_name"))
API_CALL("GET", "/collections/{collection_name}/vectors", getVectors, API_CALL("GET", "/collections/{collection_name}/vectors", getVectors,
PATH(String, collection_name, "collection_name"), QUERY(String, id)) PATH(String, collection_name, "collection_name"), QUERY(String, id))
API_CALL("POST", "/collections/{collection_name}/vectors", insert, API_CALL("POST", "/collections/{collection_name}/vectors", insert,
PATH(String, collection_name, "collection_name"), BODY_STRING(String, body)) PATH(String, collection_name, "collection_name"), BODY_STRING(String, body))
...@@ -1133,7 +1142,8 @@ TEST_F(WebControllerTest, INDEX) { ...@@ -1133,7 +1142,8 @@ TEST_F(WebControllerTest, INDEX) {
ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode());
// create index without existing table // create index without existing table
response = client_ptr->createIndex(collection_name + "fgafafafafafUUUUUUa124254", index_json.dump().c_str(), conncetion_ptr); response = client_ptr->createIndex(collection_name + "fgafafafafafUUUUUUa124254",
index_json.dump().c_str(), conncetion_ptr);
ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode());
// invalid index type // invalid index type
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册