WindowOperatorQueryFrameProcessor: Avoid unnecessary re-runs of runIncrementally()#17211
Merged
cryptoe merged 1 commit intoapache:masterfrom Oct 3, 2024
Merged
Conversation
9 tasks
kgyrtkirk
approved these changes
Oct 2, 2024
| } else { | ||
| lastPartitionIndex = rowsToProcess.size() - 1; | ||
| outputRow = currentRow.copy(); | ||
| return ReturnOrAwait.runAgain(); |
Member
There was a problem hiding this comment.
this return was insane... no wonder it have lead to performance degradation...
Comment on lines
+266
to
+271
| if (rowsToProcess.size() > maxRowsMaterialized) { | ||
| // We don't want to materialize more than maxRowsMaterialized rows at any point in time, so process the pending batch. | ||
| processRowsUpToLastPartition(); | ||
| ensureMaxRowsInAWindowConstraint(rowsToProcess.size()); | ||
| return ReturnOrAwait.runAgain(); | ||
| } |
Member
There was a problem hiding this comment.
moving this check outside here - will not necessarily enforce that maxRowsMaterialized is honored - but I guess the input frame is already materialized so we may go up to asymptotically twice in mem usage....we can leave it as is for now as this will be improved later
| ensureMaxRowsInAWindowConstraint(rowsToProcess.size()); | ||
| } else { | ||
| lastPartitionIndex = rowsToProcess.size() - 1; | ||
| outputRow = currentRow.copy(); |
Member
There was a problem hiding this comment.
this is odd; outputRow holds a direct reference to currentRow at line 254; but here its being copy-ed; I think they both should be a copy or neither of them...
but again....this will be removed so no big deal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR optimizes the scenarios where we had all window functions with some
partition byclause. Currently, we were triggering another run ofrunIncrementally()on everypartition bychange. But this is unnecessary overhead. This PR changes the behavior to only trigger a re-run when we write a frame to the output channel.For example, the below query that processes almost 50M rows was run with
maxNumTasks=2against the current master code vs this PR's code.We can see in the following screenshots that the window stage took
5:37 minutesin the current master code compared to35 secondswith this PR's code, making the overall query time to go down from 23 minutes to 18 minutes.This PR has: