perf: Optimize set operations to avoid RowConverter deserialization overhead#20623
Open
neilconway wants to merge 7 commits intoapache:mainfrom
Open
perf: Optimize set operations to avoid RowConverter deserialization overhead#20623neilconway wants to merge 7 commits intoapache:mainfrom
neilconway wants to merge 7 commits intoapache:mainfrom
Conversation
Contributor
Author
|
Benchmarks: |
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.
Which issue does this PR close?
Rationale for this change
Several array set operations (e.g.,
array_distinct,array_union,array_intersect,array_except) share a similar structure:RowConverter, ideally in bulkRowsRowsback intoArrayRefWe can do better for the final step: instead of converting from
Rowsback intoArrayRef, we can just track which indices in the input(s) correspond to the values we want to return. We can then grab those values with a singletake, which avoids theRow->ArrayRefdeserialization overhead. This is a 5-20% performance win, depending on the set operation and the characteristics of the input.The only wrinkle is that for
intersectandunion, because there are multiple inputs we need to concatenate the inputs together so that we have a single index space. It turns out that this optimization is a win, even incurring theconcatoverhead.What changes are included in this PR?
array_exceptarray_distinct,array_union,array_intersect,array_exceptAre these changes tested?
Yes, and benchmarked.
Are there any user-facing changes?
No.