提交 c3469fa5 编写于 作者: W wxyu

MS-359 Add cost test in new scheduler


Former-commit-id: 5ec53217a216927e3b0ddf211f1a56bb1a44f2b4
上级 cbc734d8
......@@ -17,6 +17,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-354 - Add task class and interface in scheduler
- MS-355 - Add copy interface in ExcutionEngine
- MS-357 - Add minimum schedule function
- MS-359 - Add cost test in new scheduler
## New Feature
- MS-343 - Implement ResourceMgr
......
......@@ -29,22 +29,23 @@ ResourceMgr::Add(ResourcePtr &&resource) {
resources_.emplace_back(resource);
size_t index = resources_.size() - 1;
resource->RegisterOnStartUp([&] {
start_up_event_[index] = true;
event_cv_.notify_one();
});
resource->RegisterOnFinishTask([&] {
finish_task_event_[index] = true;
event_cv_.notify_one();
});
resource->RegisterOnCopyCompleted([&] {
copy_completed_event_[index] = true;
event_cv_.notify_one();
});
resource->RegisterOnTaskTableUpdated([&] {
task_table_updated_event_[index] = true;
event_cv_.notify_one();
});
// TODO: update interface
// resource->RegisterOnStartUp([&] {
// start_up_event_[index] = true;
// event_cv_.notify_one();
// });
// resource->RegisterOnFinishTask([&] {
// finish_task_event_[index] = true;
// event_cv_.notify_one();
// });
// resource->RegisterOnCopyCompleted([&] {
// copy_completed_event_[index] = true;
// event_cv_.notify_one();
// });
// resource->RegisterOnTaskTableUpdated([&] {
// task_table_updated_event_[index] = true;
// event_cv_.notify_one();
// });
return ret;
}
......
......@@ -55,8 +55,7 @@ std::string Node::Dump() {
void Node::AddNeighbour(const NeighbourNodePtr &neighbour_node, Connection &connection) {
std::lock_guard<std::mutex> lk(mutex_);
if (auto s = neighbour_node.lock()) {
Neighbour neighbour(neighbour_node, connection);
neighbours_[s->id_] = neighbour;
neighbours_.emplace(std::make_pair(s->id_, Neighbour(neighbour_node, connection)));
}
// else do nothing, consider it..
}
......
......@@ -35,6 +35,7 @@ include_directories(/usr/include/mysql)
set(scheduler_test_src
${unittest_srcs}
${test_srcs}
${scheduler_resource_srcs}
${scheduler_task_srcs}
${scheduler_srcs}
......
#include "scheduler/TaskTable.h"
#include "scheduler/Cost.h"
#include <gtest/gtest.h>
using namespace zilliz::milvus::engine;
class CostTest : public ::testing::Test {
protected:
void
SetUp() override {
for (uint64_t i = 0; i < 7; ++i) {
auto task = std::make_shared<XSearchTask>();
table_.Put(task);
}
table_.Get(0).state = TaskTableItemState::INVALID;
table_.Get(1).state = TaskTableItemState::START;
table_.Get(2).state = TaskTableItemState::LOADING;
table_.Get(3).state = TaskTableItemState::LOADED;
table_.Get(4).state = TaskTableItemState::EXECUTING;
table_.Get(5).state = TaskTableItemState::EXECUTED;
table_.Get(6).state = TaskTableItemState::MOVING;
table_.Get(7).state = TaskTableItemState::MOVED;
}
TaskTable table_;
};
TEST_F(CostTest, pick_to_move) {
CacheMgr cache;
auto indexes = PickToMove(table_, cache, 10);
ASSERT_EQ(indexes.size(), 1);
ASSERT_EQ(indexes[0], 3);
}
TEST_F(CostTest, pick_to_load) {
auto indexes = PickToLoad(table_, 10);
ASSERT_EQ(indexes.size(), 1);
ASSERT_EQ(indexes[0], 1);
}
TEST_F(CostTest, pick_to_executed) {
auto indexes = PickToExecute(table_, 10);
ASSERT_EQ(indexes.size(), 1);
ASSERT_EQ(indexes[0], 3);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册