Skip to content

refactor(scheduler): share the binding driver between bind_task_bias and bind_task_round_robin - #2617

Open
cestercian wants to merge 1 commit into
apache:mainfrom
cestercian:refactor/share-bind-task-driver
Open

cestercian wants to merge 1 commit into
apache:mainfrom
cestercian:refactor/share-bind-task-driver

Conversation

@cestercian

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

bind_task_bias and bind_task_round_robin copied the same scaffolding (all-zero early return, vcores sort, running job loop, graph lock, skip/blacklist handling, bind_one call). Only the executor pick was different, and the round robin version had a hand-rolled circular scan with a scanned counter nested pretty deep.

What changes are included in this PR?

  • New private bind_tasks_with(budgets, running_jobs, if_skip, strategy) that owns all the shared parts.
  • A small BindStrategy enum (Bias, RoundRobin) with pick (which executor gets the next task) and advance (where the next search starts). Bias keeps packing the same executor and only moves forward, round robin moves to the next one and wraps.
  • next_with_capacity(budgets, start) for the circular scan. It returns None for an empty list or when everything is drained, so it no longer relies on the earlier all-zero check to avoid indexing an empty vec.
  • bind_task_bias and bind_task_round_robin keep their signatures and are now thin wrappers, so callers in memory.rs and grpc.rs are untouched. The skip log message keeps the same wording per strategy.

Are these changes tested?

Yes. The existing test_bind_task_bias / test_bind_task_round_robin tests still pass unchanged, and I added unit tests for next_with_capacity (empty, all zero, wraparound, single executor) and for the bias vs round robin pick/advance behaviour.

cargo test -p ballista-scheduler --lib cluster::   # 24 passed
cargo clippy -p ballista-scheduler --all-targets -- -D warnings
cargo fmt --all

Are there any user-facing changes?

No, scheduling behaviour is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share the binding driver between bind_task_bias and bind_task_round_robin

1 participant