Skip to content

Feature: Coordinated chunk splitting for multiple idle workers (wait-and-split) #523

Description

@SuperCoolPencil

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:

  1. Debounce / Batching: Introduce a mechanism to wait briefly and allow multiple workers to become idle before reallocating work.
  2. 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).
  3. This will ensure a much more balanced distribution of work, preventing workers from ending up with tiny chunks while others still have large ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions