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

Balanced distribution of tasks among shards #2 #1001

Closed

Conversation

4meta5
Copy link
Contributor

@4meta5 4meta5 commented Jul 10, 2024

There is a tradeoff between the computational efficiency of assigning up to the task limit to the first shard online vs the socioeconomic benefit of dynamically assigning tasks to the least assigned shard (one at a time).

WIP Closes #998

  • confirmed that task assignment is balanced iff the network task limit is set artificially low, see pallet/tasks test balanced_distribution_when_more_unassigned_tasks_than_task_limit
  • confirmed that task assignment prior to this PR is/was greedy up until the limit set for the network, see pallet/tasks test first_shard_online_assigned_up_to_task_limit
  • choose "solution" and implement it

@4meta5 4meta5 added bug Something isn't working priority: critical labels Jul 10, 2024
@4meta5 4meta5 self-assigned this Jul 10, 2024
@4meta5
Copy link
Contributor Author

4meta5 commented Jul 10, 2024

@penumbra23 @dvc94ch @0x1100010010 Part of the problem is that we sort the shards in order of least assigned tasks before iterating through them and assigning up to the task limit to each shard. This separation of sorting before batch assignment of tasks up to the limit via schedule_tasks_shard leads to the first shard being assigned the task limit number of tasks regardless of whether during its batch assignment it is assigned more tasks than other shards (the sorting is not weaved into the task assignment and this leads to the unequal distribution of tasks assigned to shards).

https://github.com/Analog-Labs/timechain/pull/928/files#r1673262307

proposed change 0

distribute tasks among ALL shards online evenly instead of greedy task assignment to the first shard assigned of up to its limit

impl draft:

  1. add input qty to schedule_tasks_shard to replace ShardTasksLimit
  2. get qty value passed into schedule_tasks_shard invocations by dividing ShardTasksLimit by the number of shards online

@4meta5 4meta5 requested a review from haider-rs July 19, 2024 00:39
@4meta5
Copy link
Contributor Author

4meta5 commented Jul 19, 2024

superseded by #1013

@4meta5 4meta5 closed this Jul 19, 2024
@4meta5 4meta5 deleted the amar-balance-task-distribution-among-shards branch July 19, 2024 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked bug Something isn't working priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task assignment to shards NOT balanced
1 participant