diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 0f4e480123c7f01d214a1d322c11d000135611e7..b9241a5e0fc28271cc941b57a2d9740f96b1080b 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -18,6 +18,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-152 - Delete assert in MySQLMetaImpl and change MySQLConnectionPool impl ## New Feature +- MS-195 - Add nlist and use_blas_threshold conf ## Task diff --git a/cpp/conf/server_config.template b/cpp/conf/server_config.template index 0383e00b53daf4c773c3534d3f7aca89d2990559..c7eb134f0d38b7c842e4f011536019ad29f517ee 100644 --- a/cpp/conf/server_config.template +++ b/cpp/conf/server_config.template @@ -33,4 +33,6 @@ cache_config: # cache configure cpu_cache_capacity: 16 # how many memory are used as cache, unit: GB, range: 0 ~ less than total memory engine_config: - nprobe: 10 \ No newline at end of file + nprobe: 10 + nlist: 16381 + use_blas_threshold: 10 \ No newline at end of file diff --git a/cpp/src/db/FaissExecutionEngine.cpp b/cpp/src/db/FaissExecutionEngine.cpp index 20bd530e78c9dc230e36e1d830abe1832d13b900..a24c8de25d807b01160c93de436c1d299ac09616 100644 --- a/cpp/src/db/FaissExecutionEngine.cpp +++ b/cpp/src/db/FaissExecutionEngine.cpp @@ -167,6 +167,7 @@ Status FaissExecutionEngine::Init() { ServerConfig &config = ServerConfig::GetInstance(); ConfigNode engine_config = config.GetConfig(CONFIG_ENGINE); nprobe_ = engine_config.GetInt32Value(CONFIG_NPROBE, 1000); + nlist_ = engine_config.GetInt32Value(CONFIG_NLIST,16384); } else if(build_index_type_ == "IDMap") { ; diff --git a/cpp/src/db/FaissExecutionEngine.h b/cpp/src/db/FaissExecutionEngine.h index f9f37ad978e0a5c5ddb8affe3057f25bd081ad97..eda0e4d70e45eb3f1e75e174f7ece8d38b2c6fa8 100644 --- a/cpp/src/db/FaissExecutionEngine.h +++ b/cpp/src/db/FaissExecutionEngine.h @@ -65,6 +65,7 @@ protected: std::string raw_index_type_; size_t nprobe_ = 0; + size_t nlist_ = 0; }; diff --git a/cpp/src/server/MilvusServer.cpp b/cpp/src/server/MilvusServer.cpp index 452ee3af88b7e429bd11833087d635bbf4012531..ae0664009cf562a1b0c10a25e5ad97c91883a074 100644 --- a/cpp/src/server/MilvusServer.cpp +++ b/cpp/src/server/MilvusServer.cpp @@ -11,6 +11,7 @@ #include "milvus_types.h" #include "milvus_constants.h" +#include "faiss/utils.h" #include #include @@ -25,6 +26,8 @@ #include #include +//extern int distance_compute_blas_threshold; + namespace zilliz { namespace milvus { namespace server { @@ -46,11 +49,12 @@ MilvusServer::StartService() { ServerConfig &config = ServerConfig::GetInstance(); ConfigNode server_config = config.GetConfig(CONFIG_SERVER); - + ConfigNode engine_config = config.GetConfig(CONFIG_ENGINE); std::string address = server_config.GetValue(CONFIG_SERVER_ADDRESS, "127.0.0.1"); int32_t port = server_config.GetInt32Value(CONFIG_SERVER_PORT, 19530); std::string protocol = server_config.GetValue(CONFIG_SERVER_PROTOCOL, "binary"); - + faiss::distance_compute_blas_threshold = engine_config.GetInt32Value(CONFIG_DCBT,20); +// std::cout<<"distance_compute_blas_threshold = "<< faiss::distance_compute_blas_threshold << std::endl; try { DBWrapper::DB();//initialize db diff --git a/cpp/src/server/ServerConfig.h b/cpp/src/server/ServerConfig.h index 0ec04eed8c935ae1e30652ea71ec2788f96e81bb..c5565b7282b4d87714040620837af690658225c1 100644 --- a/cpp/src/server/ServerConfig.h +++ b/cpp/src/server/ServerConfig.h @@ -44,6 +44,8 @@ static const std::string CONFIG_METRIC_PROMETHEUS_PORT = "port"; static const std::string CONFIG_ENGINE = "engine_config"; static const std::string CONFIG_NPROBE = "nprobe"; +static const std::string CONFIG_NLIST = "nlist"; +static const std::string CONFIG_DCBT = "use_blas_threshold"; class ServerConfig { public: diff --git a/cpp/src/wrapper/Operand.cpp b/cpp/src/wrapper/Operand.cpp index 25341676a67fd2ceebdef5f1a421a06b22f8d290..0d526198ad6fb895c1eb33078d66102e0b0e3fb9 100644 --- a/cpp/src/wrapper/Operand.cpp +++ b/cpp/src/wrapper/Operand.cpp @@ -4,6 +4,7 @@ // Proprietary and confidential. //////////////////////////////////////////////////////////////////////////////// +#include "src/server/ServerConfig.h" #include "Operand.h" @@ -38,8 +39,15 @@ string Operand::get_index_type(const int &nb) { break; } case IVF: { + + using namespace zilliz::milvus::server; + ServerConfig &config = ServerConfig::GetInstance(); + ConfigNode engine_config = config.GetConfig(CONFIG_ENGINE); + size_t nlist = engine_config.GetInt32Value(CONFIG_NLIST, 16384); + index_str += (ncent != 0 ? index_type + std::to_string(ncent) : - index_type + std::to_string(int(nb / 1000000.0 * 16384))); + index_type + std::to_string(int(nb / 1000000.0 * nlist))); +// std::cout<<"nlist = "<