提交 d5fa2d01 编写于 作者: J jinhai

Merge branch 'branch-0.4.0' into 'branch-0.4.0'

Branch 0.4.0

See merge request megasearch/milvus!553

Former-commit-id: 6e296f3d7d10786dc22d3f5a8139d94235b72c34
...@@ -56,12 +56,12 @@ resource_config: ...@@ -56,12 +56,12 @@ resource_config:
cpu: cpu:
type: CPU type: CPU
device_id: 0 device_id: 0
enable_executor: false enable_executor: true
gpu0: gpu0:
type: GPU type: GPU
device_id: 0 device_id: 0
enable_executor: true enable_executor: false
gpu_resource_num: 2 gpu_resource_num: 2
pinned_memory: 300 pinned_memory: 300
temp_memory: 300 temp_memory: 300
......
...@@ -50,6 +50,7 @@ void ...@@ -50,6 +50,7 @@ void
SearchContext::WaitResult() { SearchContext::WaitResult() {
std::unique_lock <std::mutex> lock(mtx_); std::unique_lock <std::mutex> lock(mtx_);
done_cond_.wait(lock, [this] { return map_index_files_.empty(); }); done_cond_.wait(lock, [this] { return map_index_files_.empty(); });
SERVER_LOG_DEBUG << "SearchContext " << identity_ << " all done";
} }
} }
......
...@@ -152,10 +152,10 @@ XSearchTask::Execute() { ...@@ -152,10 +152,10 @@ XSearchTask::Execute() {
return; return;
} }
ENGINE_LOG_DEBUG << "Searching in file id:" << index_id_ << " with " ENGINE_LOG_DEBUG << "Searching in file id " << index_id_ << " with "
<< search_contexts_.size() << " tasks"; << search_contexts_.size() << " tasks";
server::TimeRecorder rc("DoSearch file id:" + std::to_string(index_id_)); server::TimeRecorder rc("DoSearch file id " + std::to_string(index_id_));
server::CollectDurationMetrics metrics(index_type_); server::CollectDurationMetrics metrics(index_type_);
...@@ -163,32 +163,37 @@ XSearchTask::Execute() { ...@@ -163,32 +163,37 @@ XSearchTask::Execute() {
std::vector<float> output_distance; std::vector<float> output_distance;
for (auto &context : search_contexts_) { for (auto &context : search_contexts_) {
//step 1: allocate memory //step 1: allocate memory
auto inner_k = context->topk(); auto nq = context->nq();
auto topk = context->topk();
auto nprobe = context->nprobe(); auto nprobe = context->nprobe();
output_ids.resize(inner_k * context->nq()); auto vectors = context->vectors();
output_distance.resize(inner_k * context->nq());
output_ids.resize(topk * nq);
output_distance.resize(topk * nq);
std::string hdr = "context " + context->Identity() +
" nq " + std::to_string(nq) +
" topk " + std::to_string(topk);
try { try {
//step 2: search //step 2: search
index_engine_->Search(context->nq(), context->vectors(), inner_k, nprobe, output_distance.data(), index_engine_->Search(nq, vectors, topk, nprobe, output_distance.data(), output_ids.data());
output_ids.data());
double span = rc.RecordSection("do search for context:" + context->Identity()); double span = rc.RecordSection(hdr + ", do search");
context->AccumSearchCost(span); context->AccumSearchCost(span);
//step 3: cluster result //step 3: cluster result
SearchContext::ResultSet result_set; SearchContext::ResultSet result_set;
auto spec_k = index_engine_->Count() < context->topk() ? index_engine_->Count() : context->topk(); auto spec_k = index_engine_->Count() < topk ? index_engine_->Count() : topk;
XSearchTask::ClusterResult(output_ids, output_distance, context->nq(), spec_k, result_set); XSearchTask::ClusterResult(output_ids, output_distance, nq, spec_k, result_set);
span = rc.RecordSection("cluster result for context:" + context->Identity()); span = rc.RecordSection(hdr + ", cluster result");
context->AccumReduceCost(span); context->AccumReduceCost(span);
// step 4: pick up topk result // step 4: pick up topk result
XSearchTask::TopkResult(result_set, inner_k, metric_l2, context->GetResult()); XSearchTask::TopkResult(result_set, topk, metric_l2, context->GetResult());
span = rc.RecordSection("reduce topk for context:" + context->Identity()); span = rc.RecordSection(hdr + ", reduce topk");
context->AccumReduceCost(span); context->AccumReduceCost(span);
} catch (std::exception &ex) { } catch (std::exception &ex) {
ENGINE_LOG_ERROR << "SearchTask encounter exception: " << ex.what(); ENGINE_LOG_ERROR << "SearchTask encounter exception: " << ex.what();
......
...@@ -86,11 +86,12 @@ ErrorCode ServerConfig::ValidateConfig() { ...@@ -86,11 +86,12 @@ ErrorCode ServerConfig::ValidateConfig() {
ErrorCode ErrorCode
ServerConfig::CheckServerConfig() { ServerConfig::CheckServerConfig() {
/* /*
server_config: server_config:
address: 0.0.0.0 # milvus server ip address address: 0.0.0.0 # milvus server ip address (IPv4)
port: 19530 # the port milvus listen to, default: 19530, range: 1025 ~ 65534 port: 19530 # the port milvus listen to, default: 19530, range: 1025 ~ 65534
gpu_index: 0 # the gpu milvus use, default: 0, range: 0 ~ gpu number - 1 mode: single # milvus deployment type: single, cluster, read_only
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
*/ */
bool okay = true; bool okay = true;
ConfigNode server_config = GetConfig(CONFIG_SERVER); ConfigNode server_config = GetConfig(CONFIG_SERVER);
...@@ -144,20 +145,20 @@ ServerConfig::CheckServerConfig() { ...@@ -144,20 +145,20 @@ ServerConfig::CheckServerConfig() {
ErrorCode ErrorCode
ServerConfig::CheckDBConfig() { ServerConfig::CheckDBConfig() {
/* /*
db_config: db_config:
db_path: @MILVUS_DB_PATH@ # milvus data storage path db_path: @MILVUS_DB_PATH@ # milvus data storage path
db_slave_path: # secondry data storage path, split by semicolon db_slave_path: # secondry data storage path, split by semicolon
parallel_reduce: false # use multi-threads to reduce topk result
# URI format: dialect://username:password@host:port/database
# URI format: dialect://username:password@host:port/database # All parts except dialect are optional, but you MUST include the delimiters
# All parts except dialect are optional, but you MUST include the delimiters # Currently dialect supports mysql or sqlite
# Currently dialect supports mysql or sqlite db_backend_url: 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_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
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.
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
# 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
*/ */
bool okay = true; bool okay = true;
ConfigNode db_config = GetConfig(CONFIG_DB); ConfigNode db_config = GetConfig(CONFIG_DB);
...@@ -249,15 +250,13 @@ ServerConfig::CheckMetricConfig() { ...@@ -249,15 +250,13 @@ ServerConfig::CheckMetricConfig() {
ErrorCode ErrorCode
ServerConfig::CheckCacheConfig() { ServerConfig::CheckCacheConfig() {
/* /*
cache_config: cache_config:
cpu_cache_capacity: 16 # how many memory are used as cache, unit: GB, range: 0 ~ less than total memory 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 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 insert_cache_immediately: false # insert data will be load into cache immediately for hot query
gpu_cache_capacity: 5 # how many memory are used as cache in gpu, unit: GB, RANGE: 0 ~ less than total memory gpu_cache_capacity: 5 # how many memory are used as cache in gpu, unit: GB, RANGE: 0 ~ less than total memory
gpu_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 gpu_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
gpu_ids: # gpu id
- 0
- 1
*/ */
bool okay = true; bool okay = true;
ConfigNode cache_config = GetConfig(CONFIG_CACHE); ConfigNode cache_config = GetConfig(CONFIG_CACHE);
...@@ -379,48 +378,47 @@ ServerConfig::CheckEngineConfig() { ...@@ -379,48 +378,47 @@ ServerConfig::CheckEngineConfig() {
ErrorCode ErrorCode
ServerConfig::CheckResourceConfig() { ServerConfig::CheckResourceConfig() {
/* /*
resource_config:
resource_config: # resource list, length: 0~N
# resource list, length: 0~N # please set a DISK resource and a CPU resource least, or system will not return query result.
# please set a DISK resource and a CPU resource least, or system will not return query result. #
# # example:
# example: # resource_name: # resource name, just using in connections below
# resource_name: # resource name, just using in connections below # type: DISK # resource type, optional: DISK/CPU/GPU
# type: DISK # resource type, optional: DISK/CPU/GPU # device_id: 0
# device_id: 0 # enable_executor: false # if is enable executor, optional: true, false
# enable_executor: false # if is enable executor, optional: true, false
resources:
resources:
ssda: ssda:
type: DISK type: DISK
device_id: 0 device_id: 0
enable_executor: false enable_executor: false
cpu: cpu:
type: CPU type: CPU
device_id: 0 device_id: 0
enable_executor: false enable_executor: true
gpu0: gpu0:
type: GPU type: GPU
device_id: 0 device_id: 0
enable_executor: true enable_executor: false
gpu_resource_num: 2 gpu_resource_num: 2
pinned_memory: 300 pinned_memory: 300
temp_memory: 300 temp_memory: 300
# connection list, length: 0~N # connection list, length: 0~N
# example: # example:
# connection_name: # connection_name:
# speed: 100 # unit: MS/s # speed: 100 # unit: MS/s
# endpoint: ${resource_name}===${resource_name} # endpoint: ${resource_name}===${resource_name}
connections: connections:
io: io:
speed: 500 speed: 500
endpoint: ssda===cpu endpoint: ssda===cpu
pcie0: pcie0:
speed: 11000 speed: 11000
endpoint: cpu===gpu0 endpoint: cpu===gpu0
*/ */
bool okay = true; bool okay = true;
server::ConfigNode resource_config = GetConfig(CONFIG_RESOURCE); server::ConfigNode resource_config = GetConfig(CONFIG_RESOURCE);
......
...@@ -572,7 +572,11 @@ SearchTask::Create(const ::milvus::grpc::SearchParam *search_vector_infos, ...@@ -572,7 +572,11 @@ SearchTask::Create(const ::milvus::grpc::SearchParam *search_vector_infos,
ErrorCode ErrorCode
SearchTask::OnExecute() { SearchTask::OnExecute() {
try { try {
TimeRecorder rc("SearchTask"); int64_t top_k = search_param_->topk();
int64_t nprobe = search_param_->nprobe();
std::string hdr = "SearchTask(k=" + std::to_string(top_k) + ", nprob=" + std::to_string(nprobe) + ")";
TimeRecorder rc(hdr);
//step 1: check table name //step 1: check table name
std::string table_name_ = search_param_->table_name(); std::string table_name_ = search_param_->table_name();
...@@ -594,13 +598,11 @@ SearchTask::OnExecute() { ...@@ -594,13 +598,11 @@ SearchTask::OnExecute() {
} }
//step 3: check search parameter //step 3: check search parameter
int64_t top_k = search_param_->topk();
res = ValidationUtil::ValidateSearchTopk(top_k, table_info); res = ValidationUtil::ValidateSearchTopk(top_k, table_info);
if (res != SERVER_SUCCESS) { if (res != SERVER_SUCCESS) {
return SetError(res, "Invalid topk: " + std::to_string(top_k)); return SetError(res, "Invalid topk: " + std::to_string(top_k));
} }
int64_t nprobe = search_param_->nprobe();
res = ValidationUtil::ValidateSearchNprobe(nprobe, table_info); res = ValidationUtil::ValidateSearchNprobe(nprobe, table_info);
if (res != SERVER_SUCCESS) { if (res != SERVER_SUCCESS) {
return SetError(res, "Invalid nprobe: " + std::to_string(nprobe)); return SetError(res, "Invalid nprobe: " + std::to_string(nprobe));
......
...@@ -224,6 +224,9 @@ ValidationUtil::ValidateDbURI(const std::string &uri) { ...@@ -224,6 +224,9 @@ ValidationUtil::ValidateDbURI(const std::string &uri) {
okay = false; okay = false;
} }
/*
* Could be DNS, skip checking
*
std::string host = pieces_match[4].str(); std::string host = pieces_match[4].str();
if (!host.empty() && host != "localhost") { if (!host.empty() && host != "localhost") {
if (ValidateIpAddress(host) != SERVER_SUCCESS) { if (ValidateIpAddress(host) != SERVER_SUCCESS) {
...@@ -231,6 +234,7 @@ ValidationUtil::ValidateDbURI(const std::string &uri) { ...@@ -231,6 +234,7 @@ ValidationUtil::ValidateDbURI(const std::string &uri) {
okay = false; okay = false;
} }
} }
*/
std::string port = pieces_match[5].str(); std::string port = pieces_match[5].str();
if (!port.empty()) { if (!port.empty()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册