Skip to content

Commit 4c33402

Browse files
authored
Fix scheduler (#1359)
### What problem does this PR solve? Support cpu_limit option in infinity_conf.toml ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
1 parent 66f6880 commit 4c33402

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/scheduler/task_scheduler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ void TaskScheduler::Init(Config *config_ptr) {
5858
cpu_select_step = 1;
5959
}
6060

61-
for (u64 cpu_id = 0; cpu_id < worker_count_; cpu_id += cpu_select_step) {
61+
for (u64 cpu_id = 0, worker_id = 0; worker_id < worker_count_; ++worker_id) {
6262
UniquePtr<FragmentTaskBlockQueue> worker_queue = MakeUnique<FragmentTaskBlockQueue>();
63-
UniquePtr<Thread> worker_thread = MakeUnique<Thread>(&TaskScheduler::WorkerLoop, this, worker_queue.get(), cpu_id);
63+
UniquePtr<Thread> worker_thread = MakeUnique<Thread>(&TaskScheduler::WorkerLoop, this, worker_queue.get(), worker_id);
6464
// Pin the thread to specific cpu
6565
ThreadUtil::pin(*worker_thread, cpu_id % cpu_count);
6666

6767
worker_array_.emplace_back(cpu_id, std::move(worker_queue), std::move(worker_thread));
68-
worker_workloads_[cpu_id] = 0;
68+
worker_workloads_[worker_id] = 0;
69+
cpu_id += cpu_select_step;
6970
}
7071

7172
if (worker_array_.empty()) {

0 commit comments

Comments
 (0)