perf: Fix quadratic behavior of to_array_of_size#20459
Open
neilconway wants to merge 4 commits intoapache:mainfrom
Open
perf: Fix quadratic behavior of to_array_of_size#20459neilconway wants to merge 4 commits intoapache:mainfrom
to_array_of_size#20459neilconway wants to merge 4 commits intoapache:mainfrom
Conversation
Contributor
Author
|
Benchmarks: |
Contributor
Author
|
I see #18159 already exists for this issue; I'll be optimistic and claim this PR closes it... 😅 |
Contributor
Author
|
We could consider backing out the special-case logic in NLJ that was introduced in #18161, but that will require some consideration and benchmarking first. |
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?
ScalarValue::to_array_of_sizeis slow for StringViewArray with many buffers #20458.Utf8Viewarray buffers inScalarValue::to_array_of_size()#18159.Rationale for this change
When
array_to_size(n)was called on aList-like object containing aStringViewArraywithbdata buffers, the previous implementation returned a list containing aStringViewArraywithn*bbuffers, which leads to catastrophically bad performance ifbgrows even somewhat large.What changes are included in this PR?
Instead of using
repeat_n+concatto merge togetherncopies of theStringViewArray, we instead usetake, which preserves the same number of buffers as the inputStringViewArray.This PR also adds a new benchmark for this situation.
Are these changes tested?
Yes and benchmarked.
Are there any user-facing changes?
No.
AI usage
Iterated on the problem with Claude Code; I understand the problem and the solution.