Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread: Better load balancing #41

Open
notYuriy opened this issue May 13, 2021 · 0 comments
Open

thread: Better load balancing #41

notYuriy opened this issue May 13, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@notYuriy
Copy link
Contributor

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.
@notYuriy notYuriy added the enhancement New feature or request label May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant