Description
Currently, when a worker becomes idle, it blindly splits the largest available chunk in half. If multiple workers become idle at roughly the same time, this sequential "half-splitting" leads to suboptimal, skewed chunk sizes.
Example Scenario:
Imagine you have a download where 100 MB is pending and 3 workers become idle.
Under the current system, the sequential blind splitting results in a skewed distribution of chunk sizes: 12.5 MB, 12.5 MB, 25 MB.
The Optimal Approach:
The optimal split for 3 workers tackling 100 MB should be an even distribution: 33 MB, 33 MB, 34 MB.
Proposed Solution
Instead of immediately splitting a chunk in half whenever a single worker becomes idle, we should explore a "wait-and-split" strategy:
- Debounce / Batching: Introduce a mechanism to wait briefly and allow multiple workers to become idle before reallocating work.
- Coordinated N-way Splitting: When multiple idle workers are batched together, divide the remaining payload evenly among them (e.g., dividing by
N instead of blindly halving sequentially).
- This will ensure a much more balanced distribution of work, preventing workers from ending up with tiny chunks while others still have large ones.
Description
Currently, when a worker becomes idle, it blindly splits the largest available chunk in half. If multiple workers become idle at roughly the same time, this sequential "half-splitting" leads to suboptimal, skewed chunk sizes.
Example Scenario:
Imagine you have a download where 100 MB is pending and 3 workers become idle.
Under the current system, the sequential blind splitting results in a skewed distribution of chunk sizes:
12.5 MB, 12.5 MB, 25 MB.The Optimal Approach:
The optimal split for 3 workers tackling 100 MB should be an even distribution:
33 MB, 33 MB, 34 MB.Proposed Solution
Instead of immediately splitting a chunk in half whenever a single worker becomes idle, we should explore a "wait-and-split" strategy:
Ninstead of blindly halving sequentially).