mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
MS-574 uniform config name format, add config default value
Former-commit-id: 2d11027d4b70632e22b3100fb2bde91c86972969
This commit is contained in:
parent
7f12117031
commit
82e37e11ba
@ -1,42 +1,39 @@
|
||||
server_config:
|
||||
address: 0.0.0.0 # milvus server ip address (IPv4)
|
||||
port: 19530 # the port milvus listen to, default: 19530, range: 1025 ~ 65534
|
||||
mode: single # milvus deployment type: single, cluster, read_only
|
||||
time_zone: UTC+8 # Use the UTC-x or UTC+x to specify a time zone. eg. UTC+8 for China Standard Time
|
||||
address: 0.0.0.0 # milvus server ip address (IPv4)
|
||||
port: 19530 # port range: 1025 ~ 65534
|
||||
mode: single # deployment type: single, cluster, read_only
|
||||
time_zone: UTC+8
|
||||
|
||||
db_config:
|
||||
db_path: @MILVUS_DB_PATH@ # milvus data storage path
|
||||
db_slave_path: # secondry data storage path, split by semicolon
|
||||
db_path: @MILVUS_DB_PATH@ # milvus database path
|
||||
db_slave_path: # secondary database path, split by semicolon
|
||||
|
||||
# URI format: dialect://username:password@host:port/database
|
||||
# All parts except dialect are optional, but you MUST include the delimiters
|
||||
# Currently dialect supports mysql or sqlite
|
||||
db_backend_url: sqlite://:@:/
|
||||
|
||||
archive_disk_threshold: 0 # triger archive action if storage size exceed this value, 0 means no limit, unit: GB
|
||||
archive_days_threshold: 0 # files older than x days will be archived, 0 means no limit, unit: day
|
||||
insert_buffer_size: 4 # maximum insert buffer size allowed, default: 4, unit: GB, should be at least 1 GB.
|
||||
# the sum of insert_buffer_size and cpu_cache_capacity should be less than total memory, unit: GB
|
||||
build_index_gpu: 0 # which gpu is used to build index, default: 0, range: 0 ~ gpu number - 1
|
||||
archive_disk_threshold: 0 # GB, file will be archived when disk usage exceed, 0 for no limit
|
||||
archive_days_threshold: 0 # DAYS, older files will be archived, 0 for no limit
|
||||
buffer_size: 4 # GB, maximum insert buffer size allowed
|
||||
build_index_gpu: 0 # gpu id used for building index
|
||||
|
||||
metric_config:
|
||||
is_startup: off # if monitoring start: on, off
|
||||
collector: prometheus # metrics collector: prometheus
|
||||
prometheus_config: # following are prometheus configure
|
||||
port: 8080 # the port prometheus use to fetch metrics
|
||||
push_gateway_ip_address: 127.0.0.1 # push method configure: push gateway ip address
|
||||
push_gateway_port: 9091 # push method configure: push gateway port
|
||||
auto_bootup: off # whether enable monitoring when bootup
|
||||
collector: prometheus # prometheus
|
||||
prometheus_config:
|
||||
port: 8080 # port prometheus used to fetch metrics
|
||||
|
||||
cache_config:
|
||||
cpu_cache_capacity: 16 # how many memory are used as cache, unit: GB, range: 0 ~ less than total memory
|
||||
cpu_cache_free_percent: 0.85 # old data will be erased from cache when cache is full, this value specify how much memory should be kept, range: greater than zero ~ 1.0
|
||||
insert_cache_immediately: false # insert data will be load into cache immediately for hot query
|
||||
cpu_mem_capacity: 16 # GB, CPU memory size used for cache
|
||||
cpu_mem_threshold: 0.85 # percent of data kept when cache cleanup triggered
|
||||
insert_immediately: false # whether load data into cache when insert
|
||||
|
||||
engine_config:
|
||||
use_blas_threshold: 20
|
||||
blas_threshold: 20
|
||||
|
||||
resource_config:
|
||||
mode: simple
|
||||
resources:
|
||||
# - cpu
|
||||
pool:
|
||||
- cpu
|
||||
- gpu0
|
||||
|
||||
6
cpp/src/cache/CpuCacheMgr.cpp
vendored
6
cpp/src/cache/CpuCacheMgr.cpp
vendored
@ -30,11 +30,13 @@ namespace {
|
||||
|
||||
CpuCacheMgr::CpuCacheMgr() {
|
||||
server::ConfigNode& config = server::ServerConfig::GetInstance().GetConfig(server::CONFIG_CACHE);
|
||||
int64_t cap = config.GetInt64Value(server::CONFIG_CPU_CACHE_CAPACITY, 16);
|
||||
int64_t cap =
|
||||
config.GetInt64Value(server::CONFIG_CACHE_CPU_MEM_CAPACITY, std::stoi(server::CONFIG_CACHE_CPU_MEM_CAPACITY_DEFAULT));
|
||||
cap *= unit;
|
||||
cache_ = std::make_shared<Cache<DataObjPtr>>(cap, 1UL<<32);
|
||||
|
||||
double free_percent = config.GetDoubleValue(server::CACHE_FREE_PERCENT, 0.85);
|
||||
double free_percent =
|
||||
config.GetDoubleValue(server::CONFIG_CACHE_CPU_MEM_THRESHOLD, std::stof(server::CONFIG_CACHE_CPU_MEM_THRESHOLD_DEFAULT));
|
||||
if(free_percent > 0.0 && free_percent <= 1.0) {
|
||||
cache_->set_freemem_percent(free_percent);
|
||||
} else {
|
||||
|
||||
6
cpp/src/cache/GpuCacheMgr.cpp
vendored
6
cpp/src/cache/GpuCacheMgr.cpp
vendored
@ -35,11 +35,13 @@ namespace {
|
||||
GpuCacheMgr::GpuCacheMgr() {
|
||||
server::ConfigNode& config = server::ServerConfig::GetInstance().GetConfig(server::CONFIG_CACHE);
|
||||
|
||||
int64_t cap = config.GetInt64Value(server::CONFIG_GPU_CACHE_CAPACITY, 0);
|
||||
int64_t cap =
|
||||
config.GetInt64Value(server::CONFIG_CACHE_GPU_MEM_CAPACITY, std::stoi(server::CONFIG_CACHE_GPU_MEM_CAPACITY_DEFAULT));
|
||||
cap *= G_BYTE;
|
||||
cache_ = std::make_shared<Cache<DataObjPtr>>(cap, 1UL<<32);
|
||||
|
||||
double free_percent = config.GetDoubleValue(server::GPU_CACHE_FREE_PERCENT, 0.85);
|
||||
double free_percent =
|
||||
config.GetDoubleValue(server::CONFIG_CACHE_GPU_MEM_THRESHOLD, std::stof(server::CONFIG_CACHE_GPU_MEM_THRESHOLD_DEFAULT));
|
||||
if (free_percent > 0.0 && free_percent <= 1.0) {
|
||||
cache_->set_freemem_percent(free_percent);
|
||||
} else {
|
||||
|
||||
@ -336,7 +336,7 @@ Status ExecutionEngineImpl::Init() {
|
||||
using namespace zilliz::milvus::server;
|
||||
ServerConfig &config = ServerConfig::GetInstance();
|
||||
ConfigNode server_config = config.GetConfig(CONFIG_DB);
|
||||
gpu_num_ = server_config.GetInt32Value(CONFIG_DB_BUILD_INDEX_GPU, 0);
|
||||
gpu_num_ = server_config.GetInt32Value(CONFIG_DB_BUILD_INDEX_GPU, std::stoi(CONFIG_DB_BUILD_INDEX_GPU_DEFAULT));
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ main(int argc, char *argv[]) {
|
||||
signal(SIGUSR2, server::SignalUtil::HandleSignal);
|
||||
signal(SIGTERM, server::SignalUtil::HandleSignal);
|
||||
|
||||
server::Server &server = server::Server::Instance();
|
||||
server::Server &server = server::Server::GetInstance();
|
||||
server.Init(start_daemonized, pid_filename, config_filename, log_config_file);
|
||||
server.Start();
|
||||
|
||||
|
||||
@ -32,7 +32,8 @@ Metrics::GetInstance() {
|
||||
MetricsBase &
|
||||
Metrics::CreateMetricsCollector() {
|
||||
ConfigNode &config = ServerConfig::GetInstance().GetConfig(CONFIG_METRIC);
|
||||
std::string collector_type_str = config.GetValue(CONFIG_METRIC_COLLECTOR);
|
||||
std::string collector_type_str =
|
||||
config.GetValue(CONFIG_METRIC_COLLECTOR, CONFIG_METRIC_COLLECTOR_DEFAULT);
|
||||
|
||||
if (collector_type_str == "prometheus") {
|
||||
return PrometheusMetrics::GetInstance();
|
||||
|
||||
@ -26,15 +26,19 @@ namespace zilliz {
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
ErrorCode
|
||||
ErrorCode
|
||||
PrometheusMetrics::Init() {
|
||||
try {
|
||||
ConfigNode &configNode = ServerConfig::GetInstance().GetConfig(CONFIG_METRIC);
|
||||
startup_ = configNode.GetValue(CONFIG_METRIC_IS_STARTUP) == "on";
|
||||
if(!startup_) return SERVER_SUCCESS;
|
||||
ConfigNode &metric_config = ServerConfig::GetInstance().GetConfig(CONFIG_METRIC);
|
||||
startup_ =
|
||||
metric_config.GetBoolValue(CONFIG_METRIC_AUTO_BOOTUP, std::stoi(CONFIG_METRIC_AUTO_BOOTUP_DEFAULT));
|
||||
if (!startup_) return SERVER_SUCCESS;
|
||||
|
||||
// Following should be read from config file.
|
||||
const std::string bind_address = configNode.GetChild(CONFIG_PROMETHEUS).GetValue(CONFIG_METRIC_PROMETHEUS_PORT);
|
||||
const std::string uri = std::string("/metrics");
|
||||
ConfigNode &prometheus_config = metric_config.GetChild(CONFIG_METRIC_PROMETHEUS);
|
||||
const std::string bind_address =
|
||||
prometheus_config.GetValue(CONFIG_METRIC_PROMETHEUS_PORT, CONFIG_METRIC_PROMETHEUS_PORT_DEFAULT);
|
||||
const std::string uri = std::string("/tmp/metrics");
|
||||
const std::size_t num_threads = 2;
|
||||
|
||||
// Init Exposer
|
||||
|
||||
@ -39,12 +39,12 @@ std::mutex JobMgrInst::mutex_;
|
||||
void
|
||||
load_simple_config() {
|
||||
server::ConfigNode &config = server::ServerConfig::GetInstance().GetConfig(server::CONFIG_RESOURCE);
|
||||
auto mode = config.GetValue("mode", "simple");
|
||||
auto mode = config.GetValue(server::CONFIG_RESOURCE_MODE, server::CONFIG_RESOURCE_MODE_DEFAULT);
|
||||
|
||||
auto resources = config.GetSequence("resources");
|
||||
auto pool = config.GetSequence(server::CONFIG_RESOURCE_POOL);
|
||||
bool cpu = false;
|
||||
std::set<uint64_t> gpu_ids;
|
||||
for (auto &resource : resources) {
|
||||
for (auto &resource : pool) {
|
||||
if (resource == "cpu") {
|
||||
cpu = true;
|
||||
break;
|
||||
|
||||
@ -38,7 +38,7 @@ Status DBWrapper::StartService() {
|
||||
//db config
|
||||
engine::DBOptions opt;
|
||||
ConfigNode& db_config = ServerConfig::GetInstance().GetConfig(CONFIG_DB);
|
||||
opt.meta.backend_uri = db_config.GetValue(CONFIG_DB_URL);
|
||||
opt.meta.backend_uri = db_config.GetValue(CONFIG_DB_BACKEND_URL);
|
||||
std::string db_path = db_config.GetValue(CONFIG_DB_PATH);
|
||||
opt.meta.path = db_path + "/db";
|
||||
|
||||
@ -47,10 +47,11 @@ Status DBWrapper::StartService() {
|
||||
|
||||
// cache config
|
||||
ConfigNode& cache_config = ServerConfig::GetInstance().GetConfig(CONFIG_CACHE);
|
||||
opt.insert_cache_immediately_ = cache_config.GetBoolValue(CONFIG_INSERT_CACHE_IMMEDIATELY, false);
|
||||
opt.insert_cache_immediately_ =
|
||||
cache_config.GetBoolValue(CONFIG_CACHE_INSERT_IMMEDIATELY, std::stoi(CONFIG_CACHE_INSERT_IMMEDIATELY_DEFAULT));
|
||||
|
||||
ConfigNode& serverConfig = ServerConfig::GetInstance().GetConfig(CONFIG_SERVER);
|
||||
std::string mode = serverConfig.GetValue(CONFIG_CLUSTER_MODE, "single");
|
||||
std::string mode = serverConfig.GetValue(CONFIG_SERVER_MODE, CONFIG_SERVER_MODE_DEFAULT);
|
||||
if (mode == "single") {
|
||||
opt.mode = engine::DBOptions::MODE::SINGLE;
|
||||
}
|
||||
@ -67,7 +68,8 @@ Status DBWrapper::StartService() {
|
||||
|
||||
// engine config
|
||||
ConfigNode& engine_config = ServerConfig::GetInstance().GetConfig(CONFIG_ENGINE);
|
||||
int32_t omp_thread = engine_config.GetInt32Value(CONFIG_OMP_THREAD_NUM, 0);
|
||||
int32_t omp_thread =
|
||||
engine_config.GetInt32Value(CONFIG_ENGINE_OMP_THREAD_NUM, std::stoi(CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT));
|
||||
if(omp_thread > 0) {
|
||||
omp_set_num_threads(omp_thread);
|
||||
SERVER_LOG_DEBUG << "Specify openmp thread number: " << omp_thread;
|
||||
@ -79,12 +81,16 @@ Status DBWrapper::StartService() {
|
||||
}
|
||||
}
|
||||
|
||||
faiss::distance_compute_blas_threshold = engine_config.GetInt32Value(CONFIG_DCBT, 20);//init faiss global variable
|
||||
//init faiss global variable
|
||||
faiss::distance_compute_blas_threshold =
|
||||
engine_config.GetInt32Value(CONFIG_ENGINE_BLAS_THRESHOLD, std::stoi(CONFIG_ENGINE_BLAS_THRESHOLD_DEFAULT));
|
||||
|
||||
//set archive config
|
||||
engine::ArchiveConf::CriteriaT criterial;
|
||||
int64_t disk = db_config.GetInt64Value(CONFIG_DB_ARCHIVE_DISK, 0);
|
||||
int64_t days = db_config.GetInt64Value(CONFIG_DB_ARCHIVE_DAYS, 0);
|
||||
int64_t disk =
|
||||
db_config.GetInt64Value(CONFIG_DB_ARCHIVE_DISK_THRESHOLD, std::stoi(CONFIG_DB_ARCHIVE_DISK_THRESHOLD_DEFAULT));
|
||||
int64_t days =
|
||||
db_config.GetInt64Value(CONFIG_DB_ARCHIVE_DAYS_THRESHOLD, std::stoi(CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT));
|
||||
if(disk > 0) {
|
||||
criterial[engine::ARCHIVE_CONF_DISK] = disk;
|
||||
}
|
||||
|
||||
@ -43,18 +43,11 @@ namespace milvus {
|
||||
namespace server {
|
||||
|
||||
Server &
|
||||
Server::Instance() {
|
||||
Server::GetInstance() {
|
||||
static Server server;
|
||||
return server;
|
||||
}
|
||||
|
||||
Server::Server() {
|
||||
|
||||
}
|
||||
Server::~Server() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Server::Init(int64_t daemonized,
|
||||
const std::string &pid_filename,
|
||||
@ -171,7 +164,7 @@ Server::Start() {
|
||||
ServerConfig &config = ServerConfig::GetInstance();
|
||||
ConfigNode server_config = config.GetConfig(CONFIG_SERVER);
|
||||
|
||||
std::string time_zone = server_config.GetValue(CONFIG_TIME_ZONE, "UTC+8");
|
||||
std::string time_zone = server_config.GetValue(CONFIG_SERVER_TIME_ZONE, CONFIG_SERVER_TIME_ZONE_DEFAULT);
|
||||
if (time_zone.length() == 3) {
|
||||
time_zone = "CUT";
|
||||
} else {
|
||||
|
||||
@ -29,7 +29,7 @@ namespace server {
|
||||
|
||||
class Server {
|
||||
public:
|
||||
static Server &Instance();
|
||||
static Server &GetInstance();
|
||||
|
||||
void Init(int64_t daemonized,
|
||||
const std::string &pid_filename,
|
||||
@ -40,8 +40,8 @@ class Server {
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
Server();
|
||||
~Server();
|
||||
Server() = default;
|
||||
~Server() = default;
|
||||
|
||||
void Daemonize();
|
||||
|
||||
|
||||
@ -109,50 +109,51 @@ ServerConfig::CheckServerConfig() {
|
||||
bool okay = true;
|
||||
ConfigNode server_config = GetConfig(CONFIG_SERVER);
|
||||
|
||||
std::string ip_address = server_config.GetValue(CONFIG_SERVER_ADDRESS, "127.0.0.1");
|
||||
std::string ip_address = server_config.GetValue(CONFIG_SERVER_ADDRESS, CONFIG_SERVER_ADDRESS_DEFAULT);
|
||||
if (!ValidationUtil::ValidateIpAddress(ip_address).ok()) {
|
||||
std::cerr << "ERROR: invalid server IP address: " << ip_address << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string port_str = server_config.GetValue(CONFIG_SERVER_PORT, "19530");
|
||||
std::string port_str = server_config.GetValue(CONFIG_SERVER_PORT, CONFIG_SERVER_PORT_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(port_str).ok()) {
|
||||
std::cerr << "ERROR: port " << port_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
} else {
|
||||
int32_t port = std::stol(port_str);
|
||||
if (port < 1025 | port > 65534) {
|
||||
std::cerr << "ERROR: port " << port_str << " out of range [1025, 65534]" << std::endl;
|
||||
if (!(port > 1024 && port < 65535)) {
|
||||
std::cerr << "ERROR: port " << port_str << " out of range (1024, 65535)" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string mode = server_config.GetValue(CONFIG_CLUSTER_MODE, "single");
|
||||
std::string mode = server_config.GetValue(CONFIG_SERVER_MODE, CONFIG_SERVER_MODE_DEFAULT);
|
||||
if (mode != "single" && mode != "cluster" && mode != "read_only") {
|
||||
std::cerr << "ERROR: mode " << mode << " is not one of ['single', 'cluster', 'read_only']" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string time_zone = server_config.GetValue(CONFIG_TIME_ZONE, "UTC+8");
|
||||
std::string time_zone = server_config.GetValue(CONFIG_SERVER_TIME_ZONE, CONFIG_SERVER_TIME_ZONE_DEFAULT);
|
||||
int flag = 0;
|
||||
if(time_zone.length() < 3)
|
||||
if (time_zone.length() <= 3) {
|
||||
flag = 1;
|
||||
else if(time_zone.substr(0, 3) != "UTC")
|
||||
flag = 1;
|
||||
else if(time_zone.length() > 3){
|
||||
try {
|
||||
stoi(time_zone.substr(3, std::string::npos));
|
||||
}
|
||||
catch (std::invalid_argument &) {
|
||||
} else {
|
||||
if (time_zone.substr(0, 3) != "UTC") {
|
||||
flag = 1;
|
||||
} else {
|
||||
try {
|
||||
stoi(time_zone.substr(3));
|
||||
} catch (...) {
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flag == 1){
|
||||
std::cerr << "ERROR: time_zone " << time_zone << " is not in a right format" << std::endl;
|
||||
if (flag == 1) {
|
||||
std::cerr << "ERROR: time_zone " << time_zone << " format wrong" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
return (okay ? Status::OK() : Status(SERVER_INVALID_ARGUMENT, "Server config is illegal"));
|
||||
return (okay ? Status::OK() : Status(SERVER_INVALID_ARGUMENT, "Illegal server config"));
|
||||
}
|
||||
|
||||
Status
|
||||
@ -182,25 +183,25 @@ ServerConfig::CheckDBConfig() {
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string db_backend_url = db_config.GetValue(CONFIG_DB_URL);
|
||||
std::string db_backend_url = db_config.GetValue(CONFIG_DB_BACKEND_URL);
|
||||
if (!ValidationUtil::ValidateDbURI(db_backend_url).ok()) {
|
||||
std::cerr << "ERROR: invalid db_backend_url: " << db_backend_url << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string archive_disk_threshold_str = db_config.GetValue(CONFIG_DB_INSERT_BUFFER_SIZE, "0");
|
||||
std::string archive_disk_threshold_str = db_config.GetValue(CONFIG_DB_ARCHIVE_DISK_THRESHOLD, CONFIG_DB_ARCHIVE_DISK_THRESHOLD_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(archive_disk_threshold_str).ok()) {
|
||||
std::cerr << "ERROR: archive_disk_threshold " << archive_disk_threshold_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string archive_days_threshold_str = db_config.GetValue(CONFIG_DB_INSERT_BUFFER_SIZE, "0");
|
||||
std::string archive_days_threshold_str = db_config.GetValue(CONFIG_DB_ARCHIVE_DAYS_THRESHOLD, CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(archive_days_threshold_str).ok()) {
|
||||
std::cerr << "ERROR: archive_days_threshold " << archive_days_threshold_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string insert_buffer_size_str = db_config.GetValue(CONFIG_DB_INSERT_BUFFER_SIZE, "4");
|
||||
std::string insert_buffer_size_str = db_config.GetValue(CONFIG_DB_BUFFER_SIZE, CONFIG_DB_BUFFER_SIZE_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(insert_buffer_size_str).ok()) {
|
||||
std::cerr << "ERROR: insert_buffer_size " << insert_buffer_size_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
@ -216,7 +217,7 @@ ServerConfig::CheckDBConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string gpu_index_str = db_config.GetValue(CONFIG_DB_BUILD_INDEX_GPU, "0");
|
||||
std::string gpu_index_str = db_config.GetValue(CONFIG_DB_BUILD_INDEX_GPU, CONFIG_DB_BUILD_INDEX_GPU_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(gpu_index_str).ok()) {
|
||||
std::cerr << "ERROR: gpu_index " << gpu_index_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
@ -245,13 +246,14 @@ ServerConfig::CheckMetricConfig() {
|
||||
bool okay = true;
|
||||
ConfigNode metric_config = GetConfig(CONFIG_METRIC);
|
||||
|
||||
std::string is_startup_str = metric_config.GetValue(CONFIG_METRIC_IS_STARTUP, "off");
|
||||
std::string is_startup_str =
|
||||
metric_config.GetValue(CONFIG_METRIC_AUTO_BOOTUP, CONFIG_METRIC_AUTO_BOOTUP_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsBool(is_startup_str).ok()) {
|
||||
std::cerr << "ERROR: invalid is_startup config: " << is_startup_str << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string port_str = metric_config.GetChild(CONFIG_PROMETHEUS).GetValue(CONFIG_METRIC_PROMETHEUS_PORT, "8080");
|
||||
std::string port_str = metric_config.GetChild(CONFIG_METRIC_PROMETHEUS).GetValue(CONFIG_METRIC_PROMETHEUS_PORT, "8080");
|
||||
if (!ValidationUtil::ValidateStringIsNumber(port_str).ok()) {
|
||||
std::cerr << "ERROR: port specified in prometheus_config " << port_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
@ -274,7 +276,8 @@ ServerConfig::CheckCacheConfig() {
|
||||
bool okay = true;
|
||||
ConfigNode cache_config = GetConfig(CONFIG_CACHE);
|
||||
|
||||
std::string cpu_cache_capacity_str = cache_config.GetValue(CONFIG_CPU_CACHE_CAPACITY, "16");
|
||||
std::string cpu_cache_capacity_str =
|
||||
cache_config.GetValue(CONFIG_CACHE_CPU_MEM_CAPACITY, CONFIG_CACHE_CPU_MEM_CAPACITY_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(cpu_cache_capacity_str).ok()) {
|
||||
std::cerr << "ERROR: cpu_cache_capacity " << cpu_cache_capacity_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
@ -292,15 +295,17 @@ ServerConfig::CheckCacheConfig() {
|
||||
std::cerr << "Warning: cpu_cache_capacity value is too aggressive" << std::endl;
|
||||
}
|
||||
|
||||
uint64_t insert_buffer_size = (uint64_t) GetConfig(CONFIG_DB).GetInt32Value(CONFIG_DB_INSERT_BUFFER_SIZE, 4);
|
||||
insert_buffer_size *= GB;
|
||||
if (insert_buffer_size + cpu_cache_capacity >= total_mem) {
|
||||
uint64_t buffer_size =
|
||||
(uint64_t) GetConfig(CONFIG_DB).GetInt32Value(CONFIG_DB_BUFFER_SIZE, std::stoi(CONFIG_DB_BUFFER_SIZE_DEFAULT));
|
||||
buffer_size *= GB;
|
||||
if (buffer_size + cpu_cache_capacity >= total_mem) {
|
||||
std::cerr << "ERROR: sum of cpu_cache_capacity and insert_buffer_size exceed system memory" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string cpu_cache_free_percent_str = cache_config.GetValue(CACHE_FREE_PERCENT, "0.85");
|
||||
std::string cpu_cache_free_percent_str =
|
||||
cache_config.GetValue(CONFIG_CACHE_CPU_MEM_THRESHOLD, CONFIG_CACHE_CPU_MEM_THRESHOLD_DEFAULT);
|
||||
double cpu_cache_free_percent;
|
||||
if (!ValidationUtil::ValidateStringIsDouble(cpu_cache_free_percent_str, cpu_cache_free_percent).ok()) {
|
||||
std::cerr << "ERROR: cpu_cache_free_percent " << cpu_cache_free_percent_str << " is not a double" << std::endl;
|
||||
@ -311,13 +316,15 @@ ServerConfig::CheckCacheConfig() {
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string insert_cache_immediately_str = cache_config.GetValue(CONFIG_INSERT_CACHE_IMMEDIATELY, "false");
|
||||
std::string insert_cache_immediately_str =
|
||||
cache_config.GetValue(CONFIG_CACHE_INSERT_IMMEDIATELY, CONFIG_CACHE_INSERT_IMMEDIATELY_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsBool(insert_cache_immediately_str).ok()) {
|
||||
std::cerr << "ERROR: invalid insert_cache_immediately config: " << insert_cache_immediately_str << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string gpu_cache_capacity_str = cache_config.GetValue(CONFIG_GPU_CACHE_CAPACITY, "0");
|
||||
std::string gpu_cache_capacity_str =
|
||||
cache_config.GetValue(CONFIG_CACHE_GPU_MEM_CAPACITY, CONFIG_CACHE_GPU_MEM_CAPACITY_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(gpu_cache_capacity_str).ok()) {
|
||||
std::cerr << "ERROR: gpu_cache_capacity " << gpu_cache_capacity_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
@ -325,7 +332,7 @@ ServerConfig::CheckCacheConfig() {
|
||||
else {
|
||||
uint64_t gpu_cache_capacity = (uint64_t) std::stol(gpu_cache_capacity_str);
|
||||
gpu_cache_capacity *= GB;
|
||||
int gpu_index = GetConfig(CONFIG_DB).GetInt32Value(CONFIG_DB_BUILD_INDEX_GPU, 0);
|
||||
int gpu_index = GetConfig(CONFIG_DB).GetInt32Value(CONFIG_DB_BUILD_INDEX_GPU, std::stoi(CONFIG_DB_BUILD_INDEX_GPU_DEFAULT));
|
||||
size_t gpu_memory;
|
||||
if (!ValidationUtil::GetGpuMemory(gpu_index, gpu_memory).ok()) {
|
||||
std::cerr << "ERROR: could not get gpu memory for device " << gpu_index << std::endl;
|
||||
@ -341,7 +348,8 @@ ServerConfig::CheckCacheConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string gpu_cache_free_percent_str = cache_config.GetValue(GPU_CACHE_FREE_PERCENT, "0.85");
|
||||
std::string gpu_cache_free_percent_str =
|
||||
cache_config.GetValue(CONFIG_CACHE_GPU_MEM_THRESHOLD, CONFIG_CACHE_GPU_MEM_THRESHOLD_DEFAULT);
|
||||
double gpu_cache_free_percent;
|
||||
if (!ValidationUtil::ValidateStringIsDouble(gpu_cache_free_percent_str, gpu_cache_free_percent).ok()) {
|
||||
std::cerr << "ERROR: gpu_cache_free_percent " << gpu_cache_free_percent_str << " is not a double" << std::endl;
|
||||
@ -365,13 +373,15 @@ ServerConfig::CheckEngineConfig() {
|
||||
bool okay = true;
|
||||
ConfigNode engine_config = GetConfig(CONFIG_ENGINE);
|
||||
|
||||
std::string use_blas_threshold_str = engine_config.GetValue(CONFIG_DCBT, "20");
|
||||
std::string use_blas_threshold_str =
|
||||
engine_config.GetValue(CONFIG_ENGINE_BLAS_THRESHOLD, CONFIG_ENGINE_BLAS_THRESHOLD_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(use_blas_threshold_str).ok()) {
|
||||
std::cerr << "ERROR: use_blas_threshold " << use_blas_threshold_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
std::string omp_thread_num_str = engine_config.GetValue(CONFIG_OMP_THREAD_NUM, "0");
|
||||
std::string omp_thread_num_str =
|
||||
engine_config.GetValue(CONFIG_ENGINE_OMP_THREAD_NUM, CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT);
|
||||
if (!ValidationUtil::ValidateStringIsNumber(omp_thread_num_str).ok()) {
|
||||
std::cerr << "ERROR: omp_thread_num " << omp_thread_num_str << " is not a number" << std::endl;
|
||||
okay = false;
|
||||
@ -393,20 +403,20 @@ ServerConfig::CheckResourceConfig() {
|
||||
/*
|
||||
resource_config:
|
||||
mode: simple
|
||||
resources:
|
||||
pool:
|
||||
- cpu
|
||||
- gpu0
|
||||
- gpu100
|
||||
*/
|
||||
bool okay = true;
|
||||
server::ConfigNode &config = server::ServerConfig::GetInstance().GetConfig(server::CONFIG_RESOURCE);
|
||||
auto mode = config.GetValue("mode", "simple");
|
||||
auto mode = config.GetValue(CONFIG_RESOURCE_MODE, CONFIG_RESOURCE_MODE_DEFAULT);
|
||||
if (mode != "simple") {
|
||||
std::cerr << "ERROR: invalid resource config: mode is " << mode << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
auto resources = config.GetSequence("resources");
|
||||
if (resources.empty()) {
|
||||
auto pool = config.GetSequence(CONFIG_RESOURCE_POOL);
|
||||
if (pool.empty()) {
|
||||
std::cerr << "ERROR: invalid resource config: resources empty" << std::endl;
|
||||
okay = false;
|
||||
}
|
||||
|
||||
@ -26,52 +26,69 @@ namespace zilliz {
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
/* server config */
|
||||
static const char* CONFIG_SERVER = "server_config";
|
||||
static const char* CONFIG_SERVER_ADDRESS = "address";
|
||||
static const char* CONFIG_SERVER_ADDRESS_DEFAULT = "127.0.0.1";
|
||||
static const char* CONFIG_SERVER_PORT = "port";
|
||||
static const char* CONFIG_CLUSTER_MODE = "mode";
|
||||
static const char* CONFIG_TIME_ZONE = "time_zone";
|
||||
static const char* CONFIG_SERVER_PORT_DEFAULT = "19530";
|
||||
static const char* CONFIG_SERVER_MODE = "mode";
|
||||
static const char* CONFIG_SERVER_MODE_DEFAULT = "single";
|
||||
static const char* CONFIG_SERVER_TIME_ZONE = "time_zone";
|
||||
static const char* CONFIG_SERVER_TIME_ZONE_DEFAULT = "UTC+8";
|
||||
|
||||
/* db config */
|
||||
static const char* CONFIG_DB = "db_config";
|
||||
static const char* CONFIG_DB_URL = "db_backend_url";
|
||||
static const char* CONFIG_DB_PATH = "db_path";
|
||||
static const char* CONFIG_DB_PATH_DEFAULT = "/tmp/milvus";
|
||||
static const char* CONFIG_DB_SLAVE_PATH = "db_slave_path";
|
||||
static const char* CONFIG_DB_ARCHIVE_DISK = "archive_disk_threshold";
|
||||
static const char* CONFIG_DB_ARCHIVE_DAYS = "archive_days_threshold";
|
||||
static const char* CONFIG_DB_INSERT_BUFFER_SIZE = "insert_buffer_size";
|
||||
static const char* CONFIG_DB_PARALLEL_REDUCE = "parallel_reduce";
|
||||
static const char* CONFIG_DB_SLAVE_PATH_DEFAULT = "";
|
||||
static const char* CONFIG_DB_BACKEND_URL = "db_backend_url";
|
||||
static const char* CONFIG_DB_BACKEND_URL_DEFAULT = "sqlite://:@:/";
|
||||
static const char* CONFIG_DB_ARCHIVE_DISK_THRESHOLD = "archive_disk_threshold";
|
||||
static const char* CONFIG_DB_ARCHIVE_DISK_THRESHOLD_DEFAULT = "0";
|
||||
static const char* CONFIG_DB_ARCHIVE_DAYS_THRESHOLD = "archive_days_threshold";
|
||||
static const char* CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT = "0";
|
||||
static const char* CONFIG_DB_BUFFER_SIZE = "buffer_size";
|
||||
static const char* CONFIG_DB_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_LOG = "log_config";
|
||||
|
||||
/* cache config */
|
||||
static const char* CONFIG_CACHE = "cache_config";
|
||||
static const char* CONFIG_CPU_CACHE_CAPACITY = "cpu_cache_capacity";
|
||||
static const char* CONFIG_GPU_CACHE_CAPACITY = "gpu_cache_capacity";
|
||||
static const char* CACHE_FREE_PERCENT = "cpu_cache_free_percent";
|
||||
static const char* CONFIG_INSERT_CACHE_IMMEDIATELY = "insert_cache_immediately";
|
||||
static const char *GPU_CACHE_FREE_PERCENT = "gpu_cache_free_percent";
|
||||
static const char* CONFIG_CACHE_CPU_MEM_CAPACITY = "cpu_mem_capacity";
|
||||
static const char* CONFIG_CACHE_CPU_MEM_CAPACITY_DEFAULT = "16";
|
||||
static const char* CONFIG_CACHE_GPU_MEM_CAPACITY = "gpu_mem_capacity";
|
||||
static const char* CONFIG_CACHE_GPU_MEM_CAPACITY_DEFAULT = "0";
|
||||
static const char* CONFIG_CACHE_CPU_MEM_THRESHOLD = "cpu_mem_threshold";
|
||||
static const char* CONFIG_CACHE_CPU_MEM_THRESHOLD_DEFAULT = "0.85";
|
||||
static const char* CONFIG_CACHE_GPU_MEM_THRESHOLD = "gpu_mem_threshold";
|
||||
static const char* CONFIG_CACHE_GPU_MEM_THRESHOLD_DEFAULT = "0.85";
|
||||
static const char* CONFIG_CACHE_INSERT_IMMEDIATELY = "insert_immediately";
|
||||
static const char* CONFIG_CACHE_INSERT_IMMEDIATELY_DEFAULT = "0";
|
||||
|
||||
/* metric config */
|
||||
static const char* CONFIG_METRIC = "metric_config";
|
||||
static const char* CONFIG_METRIC_IS_STARTUP = "is_startup";
|
||||
static const char* CONFIG_METRIC_AUTO_BOOTUP = "auto_bootup";
|
||||
static const char* CONFIG_METRIC_AUTO_BOOTUP_DEFAULT = "0";
|
||||
static const char* CONFIG_METRIC_COLLECTOR = "collector";
|
||||
static const char* CONFIG_PROMETHEUS = "prometheus_config";
|
||||
static const char* CONFIG_METRIC_COLLECTOR_DEFAULT = "prometheus";
|
||||
static const char* CONFIG_METRIC_PROMETHEUS = "prometheus_config";
|
||||
static const char* CONFIG_METRIC_PROMETHEUS_PORT = "port";
|
||||
static const char* CONFIG_METRIC_PROMETHEUS_PORT_DEFAULT = "8080";
|
||||
|
||||
/* engine config */
|
||||
static const char* CONFIG_ENGINE = "engine_config";
|
||||
static const char* CONFIG_DCBT = "use_blas_threshold";
|
||||
static const char* CONFIG_OMP_THREAD_NUM = "omp_thread_num";
|
||||
static const char* CONFIG_ENGINE_BLAS_THRESHOLD = "blas_threshold";
|
||||
static const char* CONFIG_ENGINE_BLAS_THRESHOLD_DEFAULT = "20";
|
||||
static const char* CONFIG_ENGINE_OMP_THREAD_NUM = "omp_thread_num";
|
||||
static const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT = "0";
|
||||
|
||||
/* resource config */
|
||||
static const char* CONFIG_RESOURCE = "resource_config";
|
||||
static const char* CONFIG_RESOURCES = "resources";
|
||||
static const char* CONFIG_RESOURCE_TYPE = "type";
|
||||
static const char* CONFIG_RESOURCE_DEVICE_ID = "device_id";
|
||||
static const char* CONFIG_RESOURCE_ENABLE_EXECUTOR = "enable_executor";
|
||||
static const char* CONFIG_RESOURCE_NUM = "gpu_resource_num";
|
||||
static const char* CONFIG_RESOURCE_PIN_MEMORY = "pinned_memory";
|
||||
static const char* CONFIG_RESOURCE_TEMP_MEMORY = "temp_memory";
|
||||
static const char* CONFIG_RESOURCE_CONNECTIONS = "connections";
|
||||
static const char* CONFIG_SPEED_CONNECTIONS = "speed";
|
||||
static const char* CONFIG_ENDPOINT_CONNECTIONS = "endpoint";
|
||||
static const char* CONFIG_RESOURCE_MODE = "mode";
|
||||
static const char* CONFIG_RESOURCE_MODE_DEFAULT = "simple";
|
||||
static const char* CONFIG_RESOURCE_POOL = "pool";
|
||||
|
||||
|
||||
class ServerConfig {
|
||||
|
||||
@ -76,8 +76,8 @@ GrpcServer::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 address = server_config.GetValue(CONFIG_SERVER_ADDRESS, CONFIG_SERVER_ADDRESS_DEFAULT);
|
||||
int32_t port = server_config.GetInt32Value(CONFIG_SERVER_PORT, std::stoi(CONFIG_SERVER_PORT_DEFAULT));
|
||||
|
||||
std::string server_address(address + ":" + std::to_string(port));
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ void SignalUtil::HandleSignal(int signum) {
|
||||
case SIGUSR2: {
|
||||
SERVER_LOG_INFO << "Server received signal: " << signum;
|
||||
|
||||
server::Server &server = server::Server::Instance();
|
||||
server::Server &server = server::Server::GetInstance();
|
||||
server.Stop();
|
||||
|
||||
exit(0);
|
||||
@ -43,7 +43,7 @@ void SignalUtil::HandleSignal(int signum) {
|
||||
SERVER_LOG_INFO << "Server received critical signal: " << signum;
|
||||
SignalUtil::PrintStacktrace();
|
||||
|
||||
server::Server &server = server::Server::Instance();
|
||||
server::Server &server = server::Server::GetInstance();
|
||||
server.Stop();
|
||||
|
||||
exit(1);
|
||||
|
||||
@ -41,14 +41,15 @@ ErrorCode KnowhereResource::Initialize() {
|
||||
server::ServerConfig& root_config = server::ServerConfig::GetInstance();
|
||||
server::ConfigNode& db_config = root_config.GetConfig(server::CONFIG_DB);
|
||||
|
||||
int32_t build_index_gpu = db_config.GetInt32Value(server::CONFIG_DB_BUILD_INDEX_GPU, 0);
|
||||
int32_t build_index_gpu =
|
||||
db_config.GetInt32Value(server::CONFIG_DB_BUILD_INDEX_GPU, std::stoi(server::CONFIG_DB_BUILD_INDEX_GPU_DEFAULT));
|
||||
gpu_resources.insert(std::make_pair(build_index_gpu, GpuResourceSetting()));
|
||||
|
||||
//get search gpu resource
|
||||
server::ConfigNode& res_config = root_config.GetConfig(server::CONFIG_RESOURCE);
|
||||
auto resources = res_config.GetSequence("resources");
|
||||
auto pool = res_config.GetSequence(server::CONFIG_RESOURCE_POOL);
|
||||
std::set<uint64_t> gpu_ids;
|
||||
for (auto &resource : resources) {
|
||||
for (auto &resource : pool) {
|
||||
if (resource.length() < 4 || resource.substr(0, 3) != "gpu") {
|
||||
// invalid
|
||||
continue;
|
||||
|
||||
@ -67,7 +67,7 @@ class RpcHandlerTest : public testing::Test {
|
||||
engine::DBOptions opt;
|
||||
|
||||
server::ConfigNode &db_config = server::ServerConfig::GetInstance().GetConfig(server::CONFIG_DB);
|
||||
db_config.SetValue(server::CONFIG_DB_URL, "sqlite://:@:/");
|
||||
db_config.SetValue(server::CONFIG_DB_BACKEND_URL, "sqlite://:@:/");
|
||||
db_config.SetValue(server::CONFIG_DB_PATH, "/tmp/milvus_test");
|
||||
db_config.SetValue(server::CONFIG_DB_SLAVE_PATH, "");
|
||||
db_config.SetValue(server::CONFIG_DB_ARCHIVE_DISK, "");
|
||||
@ -77,7 +77,7 @@ class RpcHandlerTest : public testing::Test {
|
||||
cache_config.SetValue(server::CONFIG_INSERT_CACHE_IMMEDIATELY, "");
|
||||
|
||||
server::ConfigNode &engine_config = server::ServerConfig::GetInstance().GetConfig(server::CONFIG_ENGINE);
|
||||
engine_config.SetValue(server::CONFIG_OMP_THREAD_NUM, "");
|
||||
engine_config.SetValue(server::CONFIG_ENGINE_OMP_THREAD_NUM, "");
|
||||
|
||||
server::ConfigNode &serverConfig = server::ServerConfig::GetInstance().GetConfig(server::CONFIG_SERVER);
|
||||
// serverConfig.SetValue(server::CONFIG_CLUSTER_MODE, "cluster");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user