mirror of https://github.com/milvus-io/milvus.git
release search task in time (#3609)
Signed-off-by: shengjun.li <shengjun.li@zilliz.com>pull/3660/head
parent
d5ecdf2dda
commit
18c630a4be
|
@ -4,6 +4,7 @@ Please mark all change in change log and use the issue from GitHub
|
|||
|
||||
# Milvus 0.10.3 (TBD)
|
||||
## Bug
|
||||
- \#3536 Release search task in time to avoid excessive memory usage
|
||||
|
||||
## Feature
|
||||
- \#3213 Allow users to specify a distance type at runtime for Flat index
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "scheduler/resource/Resource.h"
|
||||
#include "scheduler/SchedInst.h"
|
||||
#include "scheduler/Utils.h"
|
||||
#include "scheduler/task/FinishedTask.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
@ -116,8 +117,9 @@ Resource::pick_task_load() {
|
|||
auto indexes = task_table_.PickToLoad(10);
|
||||
for (auto index : indexes) {
|
||||
// try to set one task loading, then return
|
||||
if (task_table_.Load(index))
|
||||
if (task_table_.Load(index)) {
|
||||
return task_table_.at(index);
|
||||
}
|
||||
// else try next
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -172,6 +174,7 @@ Resource::loader_function() {
|
|||
task_item->Loaded();
|
||||
if (task_item->from) {
|
||||
task_item->from->Moved();
|
||||
task_item->from->task = FinishedTask::Create(task_item->from->task);
|
||||
task_item->from = nullptr;
|
||||
}
|
||||
if (subscriber_) {
|
||||
|
@ -201,6 +204,7 @@ Resource::executor_function() {
|
|||
}
|
||||
auto start = get_current_timestamp();
|
||||
Process(task_item->task);
|
||||
task_item->task = FinishedTask::Create(task_item->task);
|
||||
auto finish = get_current_timestamp();
|
||||
++total_task_;
|
||||
total_cost_ += finish - start;
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// 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.
|
||||
|
||||
#include "scheduler/task/FinishedTask.h"
|
||||
|
||||
namespace milvus::scheduler {
|
||||
|
||||
std::shared_ptr<FinishedTask>
|
||||
FinishedTask::Create(const TaskPtr& task) {
|
||||
return std::make_shared<FinishedTask>(task);
|
||||
}
|
||||
|
||||
FinishedTask::FinishedTask(const TaskPtr& task) : Task(TaskType::SearchTask, nullptr) {
|
||||
Task::task_path_ = task->task_path_;
|
||||
Task::type_ = task->type_;
|
||||
Task::label_ = task->label_;
|
||||
}
|
||||
|
||||
void
|
||||
FinishedTask::Load(LoadType type, uint8_t device_id) {
|
||||
}
|
||||
|
||||
void
|
||||
FinishedTask::Execute() {
|
||||
}
|
||||
|
||||
} // namespace milvus::scheduler
|
|
@ -0,0 +1,35 @@
|
|||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scheduler/task/Task.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace milvus::scheduler {
|
||||
|
||||
class FinishedTask : public Task {
|
||||
public:
|
||||
static std::shared_ptr<FinishedTask>
|
||||
Create(const TaskPtr& task);
|
||||
|
||||
public:
|
||||
explicit FinishedTask(const TaskPtr& task);
|
||||
|
||||
void
|
||||
Load(LoadType type, uint8_t device_id) override;
|
||||
|
||||
void
|
||||
Execute() override;
|
||||
};
|
||||
|
||||
} // namespace milvus::scheduler
|
|
@ -314,7 +314,6 @@ XSearchTask::Execute() {
|
|||
}
|
||||
}
|
||||
search_job->SearchDone(index_id_);
|
||||
index_engine_ = nullptr;
|
||||
return;
|
||||
}
|
||||
if (!vectors.float_data_.empty()) {
|
||||
|
@ -366,9 +365,6 @@ XSearchTask::Execute() {
|
|||
}
|
||||
|
||||
rc.ElapseFromBegin("totally cost");
|
||||
|
||||
// release index in resource
|
||||
index_engine_ = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue