Skip to content

Comments

Use NodeAssignmentStats::getQueuedSplitsWeightForStage in task-based split scheduling#26124

Merged
spershin merged 1 commit intoprestodb:masterfrom
spershin:ImproveTaskBasedSplitScheduling
Sep 23, 2025
Merged

Use NodeAssignmentStats::getQueuedSplitsWeightForStage in task-based split scheduling#26124
spershin merged 1 commit intoprestodb:masterfrom
spershin:ImproveTaskBasedSplitScheduling

Conversation

@spershin
Copy link
Contributor

@spershin spershin commented Sep 22, 2025

Description

In the initial PR which introduces "task-based split scheduling" in the last update I have replaced assignmentStats.getQueuedSplitsWeightForStage(node) calls by assignmentStats.getAssignedSplitsWeightForStage(node) thinking that we get queued splits from the TaskStatus and don't need extra queued from the NodeAssignmentStats.

But as it happened, while working on the issue of HttpRemoteTaskWithEventLoop, I noticed that the getQueuedSplitsWeightForStage is a misnomer and actually returns not queued, but scheduled and unacknowled splits plus the splits what we assigned in the current split scheduling run.
While getAssignedSplitsWeightForStage only returns splits what we assigned in the current split scheduling run.

This PR fixes it.

Actually, it would be good to follow up this with a PR doing some renaming in the NodeAssignmentStats and HttpRemoteTask classes as we have the same things called different names and different things called the same names and also some methods returning A + B not reflecting this in their names.
Hard to follow and reason about the code.

getQueuedSplitsWeightForStage::getAssignedSplitsWeightForStage()
  return PendingSplitInfo.assignedSplitsWeight

getQueuedSplitsWeightForStage::getQueuedSplitsWeightForStage()
  return PendingSplitInfo::queuedSplitsWeight + PendingSplitInfo.assignedSplitsWeight

PendingSplitInfo::queuedSplitsWeight is initialized in the ctor from PartitionedSplitsInfo.getWeightSum() which comes from RemoteTask::getQueuedPartitionedSplitsInfo, which is:
  return HttpRemoteTask.pendingSourceSplitsWeight + TaskStatus.queuedPartitionedSplitsWeight where:
    HttpRemoteTask.pendingSourceSplitsWeight is the weight of splits from the assigned, but not yet acknowledged by the worker splits.
    TaskStatus.queuedPartitionedSplitsWeight is the last known weight of splits queued on the worker

PendingSplitInfo.assignedSplitsWeight is changed in addAssignedSplit() within a single split assignment iteration and will start at zero for the next iteration.
== NO RELEASE NOTE ==

@spershin spershin requested a review from a team as a code owner September 22, 2025 22:32
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Sep 22, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 22, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Corrects split weight calculations in task-based split scheduling by switching to NodeAssignmentStats.getQueuedSplitsWeightForStage to include scheduled but unacknowledged splits and cleans up an unused test variable.

Sequence diagram for split weight calculation in task-based split scheduling

sequenceDiagram
participant "SimpleNodeSelector"
participant "NodeAssignmentStats"
participant "RemoteTask"
participant "TaskStatus"
participant "InternalNode"
"SimpleNodeSelector" ->> "InternalNode": getNodeIdentifier()
"SimpleNodeSelector" ->> "RemoteTask": get task for node
alt No RemoteTask for node
    "SimpleNodeSelector" ->> "NodeAssignmentStats": getQueuedSplitsWeightForStage(node)
else RemoteTask exists
    "SimpleNodeSelector" ->> "RemoteTask": getTaskStatus()
    "SimpleNodeSelector" ->> "TaskStatus": getRunningPartitionedSplitsWeight()
    "SimpleNodeSelector" ->> "NodeAssignmentStats": getQueuedSplitsWeightForStage(node)
end
Loading

Class diagram for NodeAssignmentStats and related split weight methods

classDiagram
class NodeAssignmentStats {
  +getQueuedSplitsWeightForStage(node)
  +getAssignedSplitsWeightForStage(node)
}
class TaskStatus {
  +getQueuedPartitionedSplitsWeight()
  +getRunningPartitionedSplitsWeight()
}
class RemoteTask {
  +getTaskStatus()
}
class InternalNode {
  +getNodeIdentifier()
}
NodeAssignmentStats --> InternalNode
RemoteTask --> TaskStatus
Loading

File-Level Changes

Change Details Files
Use queued splits weight provider in SimpleNodeSelector
  • For nodes without tasks, return getQueuedSplitsWeightForStage instead of getAssignedSplitsWeightForStage
  • For nodes with tasks, sum running splits weight and getQueuedSplitsWeightForStage (removing the old assigned splits weight)
presto-main-base/src/main/java/com/facebook/presto/execution/scheduler/nodeSelection/SimpleNodeSelector.java
Cleanup unused variable in TestNodeScheduler
  • Removed unused Map<RemoteTask, Multimap<PlanNodeId, Split>> splitsForTasks declaration
presto-main-base/src/test/java/com/facebook/presto/execution/TestNodeScheduler.java

Possibly linked issues

  • Don't contact metastore when reading data #123: The PR corrects the split weight calculation in the SimpleNodeSelector, which is essential for achieving the even split scheduling requested by the issue by accurately reflecting node load.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@spershin spershin requested a review from rschlussel September 22, 2025 22:32
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Consider renaming getQueuedSplitsWeightForStage (and related methods) to something more descriptive—e.g. reflecting that it includes scheduled and unacknowledged splits—to reduce confusion in the scheduling logic.
  • Add a unit test that explicitly verifies the node load provider now sums running and queued split weights correctly, so this subtle behavior is protected from future regressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider renaming getQueuedSplitsWeightForStage (and related methods) to something more descriptive—e.g. reflecting that it includes scheduled and unacknowledged splits—to reduce confusion in the scheduling logic.
- Add a unit test that explicitly verifies the node load provider now sums running and queued split weights correctly, so this subtle behavior is protected from future regressions.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@spershin spershin merged commit 850cc31 into prestodb:master Sep 23, 2025
75 of 77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:Meta PR from Meta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants