Skip to content

Commit

Permalink
One step further
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouncner committed Dec 2, 2022
1 parent f776975 commit 8de1375
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 49 deletions.
51 changes: 4 additions & 47 deletions src/lib/scheduler/node_queue_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#include "utils/assert.hpp"


namespace {
//namespace {

//constexpr auto MIN_LOAD_TO_DISTRIBUTE_TASKS = size_t{128};

}
//}

namespace hyrise {

Expand All @@ -38,8 +38,8 @@ void NodeQueueScheduler::begin() {
DebugAssert(!_active, "Scheduler is already active");

_workers.reserve(Hyrise::get().topology.num_cpus());
_queue_count = Hyrise::get().topology.nodes().size();
_queues.reserve(_queue_count);
//_queue_count = Hyrise::get().topology.nodes().size();
_queues.reserve(Hyrise::get().topology.nodes().size());

for (auto node_id = NodeID{0}; node_id < Hyrise::get().topology.nodes().size(); node_id++) {
auto queue = std::make_shared<TaskQueue>(node_id);
Expand All @@ -53,7 +53,6 @@ void NodeQueueScheduler::begin() {
std::make_shared<Worker>(queue, WorkerID{_worker_id_allocator->allocate()}, topology_cpu.cpu_id));
}
}
_worker_count = _workers.size();
_active = true;

for (auto& worker : _workers) {
Expand Down Expand Up @@ -130,50 +129,8 @@ void NodeQueueScheduler::schedule(std::shared_ptr<AbstractTask> task, NodeID pre
if (preferred_node_id == CURRENT_NODE_ID) {
auto worker = Worker::get_this_thread_worker();
if (worker) {
//std::cout << "default path\n";
preferred_node_id = worker->queue()->node_id();
/* } else if (_queue_count > 1) {
//std::stringstream ss;
//ss << "new path. previously default to 0. now we check the lengths: ";
//for (const auto& queue : _queues) {
// ss << queue->estimate_load() << " and ";
//}
auto min_load_queue_id = size_t{0};
const auto load_queue_0 = _queues[0]->estimate_load();
auto min_load = load_queue_0;
if (min_load >= MIN_LOAD_TO_DISTRIBUTE_TASKS) {
//autostd::vector<std::pair<NodeID, size_t>>(_queue_count);
for (auto queue_id = size_t{1}; queue_id < _queue_count; ++queue_id) {
const auto queue_load = _queues[queue_id]->estimate_load();
if (queue_load < min_load) {
min_load_queue_id = queue_id;
min_load = queue_load;
}
}
//const auto min_queue = std::min_element(_queues.cbegin(), _queues.cend(), [](const auto& lhs, const auto& rhs) {
//std::printf("loads: %lu & %lu\n", lhs->estimate_load(), lhs->estimate_load());
//return lhs->estimate_load() < lhs->estimate_load();
//});
//std::printf("%lu",std::distance(_queues.cbegin(), min_queue));
if (load_queue_0 >= MIN_LOAD_TO_DISTRIBUTE_TASKS) {
preferred_node_id = NodeID{static_cast<uint32_t>(min_load_queue_id)};
//std::printf("(%d)\n", static_cast<uint32_t>(preferred_node_id));
} else {
preferred_node_id = NodeID{0};
}
//ss << " and chose queue id: " << preferred_node_id << "\n";
//std::cout << ss.str() << std::flush;
} else {
preferred_node_id = NodeID{0};
}
*/
} else {
//std::printf("Else\n");
preferred_node_id = NodeID{0};
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib/scheduler/node_queue_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ class NodeQueueScheduler : public AbstractScheduler {
std::vector<std::shared_ptr<TaskQueue>> _queues;
std::vector<std::shared_ptr<Worker>> _workers;
std::atomic_bool _active{false};
size_t _worker_count{1};
size_t _queue_count{1};
};

} // namespace hyrise

0 comments on commit 8de1375

Please sign in to comment.