-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WindowOperatorQueryFrameProcessor: Fix frame writer capacity issues + adhere to FrameProcessor's contract #17209
Conversation
… adhere to FrameProcessor's contract
this seems like a bugfix - please remove the optimization; that should be reviewed separetly |
@kgyrtkirk I think we anyway should get the optimization also merged for Druid 31 (since it's significant), hence bundled it together with this patch because it was already updating a lot of the frame writer logic. If it helps, this part of the diff corresponds to the optimization: |
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Outdated
Show resolved
Hide resolved
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Show resolved
Hide resolved
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Outdated
Show resolved
Hide resolved
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Outdated
Show resolved
Hide resolved
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Show resolved
Hide resolved
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Show resolved
Hide resolved
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Show resolved
Hide resolved
remove the performance enhancement ; and place it in a separate PR - also add a benchmark to help keep track of performance improvements |
@kgyrtkirk I was hoping to keep all changes related to frame writer together, to ensure that everything works fine with both of them together. Instead of a bug fix PR, I'm looking at this PR as more of a "revamp frame writer logic in WindowOperatorQueryFrameProcessor" PR. Splitting it into multiple PRs is certainly doable, but I'd still have to continue testing them coupled together locally, which is unnecessary and would cause unnecessary delays (we are hoping to get this in for Druid 31 release). Regarding the benchmark - I agree that it would be great to have it. It's on my list of todos, but it's not a trivial task and would require some time. So until then, benchmark shouldn't block any performance improvements / logic changes. Thoughts? cc: @cryptoe |
what's happening in this PR right now is pretty convoluted - that's why I'm asking to remove any performance enhancements ; because I don't think the fix for the bug is right |
@kgyrtkirk Fair enough, working on splitting up the PR. |
@kgyrtkirk Have removed the optimization diff from this PR. Have opened a separate PR for it: #17211, appreciate your reviews on that PR as well. Thanks! |
220450c
to
547e51d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good; just a minor comment :)
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Outdated
Show resolved
Hide resolved
...age-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryFrameProcessor.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the updates!
+1
* @throws IOException | ||
*/ | ||
private void flushAllRowsAndCols(ArrayList<RowsAndColumns> resultRowAndCols) throws IOException | ||
private void flushAllRowsAndCols() throws IOException | ||
{ | ||
RowsAndColumns rac = new ConcatRowsAndColumns(resultRowAndCols); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its just performance: but the creation of this rac is an O(n)
operation; regardless where the rowId
stands.
that's why it would have been better to just pack all these things into an inner-workhorse class....when that will be done this should be taken into account.
… adhere to FrameProcessor's contract (apache#17209) This PR fixes the above issue by maintaining the state of last rowId flushed to output channel, and triggering another iteration of runIncrementally() method if frame writer has rows pending flush to the output channel. The above is done keeping in mind FrameProcessor's contract which enforces that we should write only a single frame to each output channel in any given iteration of runIncrementally().
Description
Currently, we had a bug in the
WindowOperatorQueryFrameProcessor
where the frame writer's capacity could get reached for larger queries, causing it to not output all of the result rows.For example, the following query gives incomplete output rows when we use
maxNumTasks=2
, compared to when we use more workers.This PR fixes the above issue by maintaining the state of
last rowId flushed to output channel
, and triggering another iteration ofrunIncrementally()
method if frame writer has rows pending flush to the output channel.The above is done keeping in mind
FrameProcessor
's contract which enforces that we should write only a single frame to each output channel in any given iteration ofrunIncrementally()
.For manual testing, I've been verifying the behavior with queries like the following:
Additionally, I have added a test
WindowOperatorQueryFrameProcessorTest#testFrameWriterReachingCapacity()
which was previously writing less number of rows to the output channel, but is writing the complete set of rows.This PR has: