Skip to content

thread: Better load balancing #41

@notYuriy

Description

@notYuriy

As of now, task allocator is very simplistic

var best_cpu_idx: usize = 0;
{
const state = balancer_lock.lock();
// TODO: maybe something more sophisticated?
for (os.platform.smp.cpus) |*cpu, i| {
if (cpu.tasks_count < os.platform.smp.cpus[best_cpu_idx].tasks_count) {
best_cpu_idx = i;
}
}
task.allocated_core_id = best_cpu_idx;
os.platform.smp.cpus[best_cpu_idx].tasks_count += 1;
balancer_lock.unlock(state);
}

There are two possible ways to improve task allocation algorithm

  • Better way to measure load than simply number of tasks. Ideally, we want to measure how much time is spent in each of those tasks using os.platform.clock() function
  • Use a better data structure than array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions