diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index c66b1df7fe09f1ad3b5f03333d4b0435fa51effc..671d865a028b5851662e2798131cb2289b70088e 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -5,6 +5,8 @@ Please mark all change in change log and use the ticket from JIRA. # Milvus 0.4.0 (2019-07-28) ## Bug +- MS-411 - Fix metric unittest linking error +- MS-412 - Fix gpu cache logical error ## Improvement - MS-327 - Clean code for milvus @@ -47,6 +49,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-407 - Reconstruct MetricsCollector - MS-408 - Add device_id in resource construct function - MS-409 - Using new scheduler +- MS-410 - Add resource config comment ## New Feature - MS-343 - Implement ResourceMgr diff --git a/cpp/conf/server_config.template b/cpp/conf/server_config.template index 2792fbf5daa66ab8bc7f5aa4557209d4f6bf4810..0a363eff8cf3a6010fb00d9084cb69352230f507 100644 --- a/cpp/conf/server_config.template +++ b/cpp/conf/server_config.template @@ -41,6 +41,17 @@ engine_config: omp_thread_num: 0 # how many compute threads be used by engine, 0 means use all cpu core to compute resource_config: + # resource list, length: 0~N + # please set a DISK resource and a CPU resource least, or system will not return query result. + # + # example: + # resource_name: # resource name, just using in connections below + # type: DISK # resource type, optional: DISK/CPU/GPU + # memory: 256 # memory size, unit: GB + # device_id: 0 + # enable_loader: true # if is enable loader, optional: true, false + # enable_executor: false # if is enable executor, optional: true, false + resources: ssda: type: DISK @@ -70,7 +81,10 @@ resource_config: enable_loader: true enable_executor: true + # connection list, length: 0~N + # format: -${resource_name}===${resource_name} connections: - ssda===cpu - cpu===gtx1060 - cpu===gtx1660 + diff --git a/cpp/src/db/engine/ExecutionEngineImpl.cpp b/cpp/src/db/engine/ExecutionEngineImpl.cpp index 5ef2fc0c72c2bacbd77724883ed0fc1a059785d7..7489e7849e3b407669948ae382fba465380cb1e8 100644 --- a/cpp/src/db/engine/ExecutionEngineImpl.cpp +++ b/cpp/src/db/engine/ExecutionEngineImpl.cpp @@ -139,9 +139,11 @@ Status ExecutionEngineImpl::Load(bool to_cache) { } Status ExecutionEngineImpl::CopyToGpu(uint64_t device_id) { - index_ = zilliz::milvus::cache::GpuCacheMgr::GetInstance(device_id)->GetIndex(location_); - bool already_in_cache = (index_ != nullptr); - if (!index_) { + auto index = zilliz::milvus::cache::GpuCacheMgr::GetInstance(device_id)->GetIndex(location_); + bool already_in_cache = (index != nullptr); + if (already_in_cache) { + index_ = index; + } else { try { index_ = index_->CopyToGpu(device_id); ENGINE_LOG_DEBUG << "CPU to GPU" << device_id; @@ -161,9 +163,11 @@ Status ExecutionEngineImpl::CopyToGpu(uint64_t device_id) { } Status ExecutionEngineImpl::CopyToCpu() { - index_ = zilliz::milvus::cache::CpuCacheMgr::GetInstance()->GetIndex(location_); - bool already_in_cache = (index_ != nullptr); - if (!index_) { + auto index = zilliz::milvus::cache::CpuCacheMgr::GetInstance()->GetIndex(location_); + bool already_in_cache = (index != nullptr); + if (already_in_cache) { + index_ = index; + } else { try { index_ = index_->CopyToCpu(); ENGINE_LOG_DEBUG << "GPU to CPU"; @@ -175,7 +179,7 @@ Status ExecutionEngineImpl::CopyToCpu() { } } - if(!already_in_cache) { + if (!already_in_cache) { Cache(); } return Status::OK(); @@ -276,7 +280,7 @@ Status ExecutionEngineImpl::Init() { using namespace zilliz::milvus::server; ServerConfig &config = ServerConfig::GetInstance(); ConfigNode server_config = config.GetConfig(CONFIG_SERVER); - gpu_num_ = server_config.GetInt32Value("gpu_index", 0); + gpu_num_ = server_config.GetInt32Value("gpu_index", 0); return Status::OK(); } diff --git a/cpp/src/scheduler/action/PushTaskToNeighbour.cpp b/cpp/src/scheduler/action/PushTaskToNeighbour.cpp index 7c5855c11181a6b481e026608f6baaae9f17b75f..9afeac688a5ff1ce9126c1e619d99d5427467110 100644 --- a/cpp/src/scheduler/action/PushTaskToNeighbour.cpp +++ b/cpp/src/scheduler/action/PushTaskToNeighbour.cpp @@ -5,6 +5,7 @@ ******************************************************************************/ #include +#include #include "Action.h" @@ -38,6 +39,22 @@ push_task_round_robin(TaskTable &self_task_table, std::list &neighb } } +void +push_task_randomly(TaskTable &self_task_table, std::vector &neighbours) { + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution dist(0, neighbours.size() - 1); + CacheMgr cache; + + auto indexes = PickToMove(self_task_table, cache, self_task_table.Size()); + for (auto index : indexes) { + if (self_task_table.Move(index)) { + auto task = self_task_table.Get(index)->task; + neighbours[dist(mt)]->task_table().Put(task); + } + } +} + void Action::PushTaskToNeighbour(const ResourceWPtr &res) { auto self = res.lock(); @@ -60,18 +77,21 @@ Action::PushTaskToNeighbourHasExecutor(const ResourceWPtr &res) { auto self = res.lock(); if (not self) return; - std::list neighbours; + std::list l_neighbours; + std::vector v_neighbours; for (auto &neighbour_node : self->GetNeighbours()) { auto node = neighbour_node.neighbour_node.lock(); if (not node) continue; auto resource = std::static_pointer_cast(node); if (resource->HasExecutor()) { - neighbours.emplace_back(resource); + l_neighbours.push_back(resource); + v_neighbours.push_back(resource); } } - push_task_round_robin(self->task_table(), neighbours); +// push_task_round_robin(self->task_table(), l_neighbours); + push_task_randomly(self->task_table(), v_neighbours); } diff --git a/cpp/unittest/metrics/CMakeLists.txt b/cpp/unittest/metrics/CMakeLists.txt index 47b86d11078ada8a268047ce1ee249a1e1890f9a..c066165a2c9aa83c7de79c515aef5aa03d60d341 100644 --- a/cpp/unittest/metrics/CMakeLists.txt +++ b/cpp/unittest/metrics/CMakeLists.txt @@ -19,6 +19,11 @@ aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files) aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_srcs) aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_src) aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper/knowhere knowhere_src) +aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/action scheduler_action_srcs) +aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/event scheduler_event_srcs) +aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/resource scheduler_resource_srcs) +aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/task scheduler_task_srcs) +aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler scheduler_srcs) aux_source_directory(${MILVUS_ENGINE_SRC}/src/metrics metrics_src) aux_source_directory(./ test_srcs) @@ -52,6 +57,11 @@ set(count_test_src ${db_meta_files} ${db_scheduler_srcs} ${wrapper_src} + ${scheduler_action_srcs} + ${scheduler_event_srcs} + ${scheduler_resource_srcs} + ${scheduler_task_srcs} + ${scheduler_srcs} ${knowhere_src} ${metrics_src} ${test_srcs}