perf: Improve efficiency of array_resize for sliced arrays - #25479
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25479 +/- ##
==========================================
+ Coverage 82.34% 82.38% +0.04%
==========================================
Files 1137 1138 +1
Lines 432364 433776 +1412
Branches 432364 433776 +1412
==========================================
+ Hits 356020 357362 +1342
- Misses 54830 54855 +25
- Partials 21514 21559 +45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jayzhan211
approved these changes
Sep 19, 2026
jayzhan211
left a comment
Contributor
There was a problem hiding this comment.
Thanks @neilconway , all minor suggestions
| let count = O::usize_as(count); | ||
| let start = offset_window[0]; | ||
| if start + count > offset_window[1] { | ||
| debug_assert!( |
Contributor
There was a problem hiding this comment.
debug_assert! is compiled out in release; a violated invariant then becomes an index-OOB panic inside MutableArrayData::try_extend(1, ..). Return an internal error instead:
- debug_assert!(
- default_value_data.is_some(),
- "fill values are required when growing a list"
- );
+ if default_value_data.is_none() {
+ return internal_err!(
+ "array_resize: fill values are required when growing a list"
+ );
+ }
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
array_resizeprepares fill/padding values for the situations in which it needs to grow the input arrays. When (a) no fill value was provided, and (b) no row needs to grow, the code allocated an all-NULL array equal to the size of the underlying backing array of the to-be-resized input. This is redundant, because no fill is needed; it's also potentially expensive, because the backing array might be much larger than the actual visible portion of the input.Benchmarks:
Other benchmark cases were within noise.
What changes are included in this PR?
build_resized_listto make the fill dataOptionalWhat is the testing strategy for this PR?
Benchmarked to confirm performance improvement. Existing tests pass. Added new unit tests to improve code coverage; they are not intended to catch the allocation change though.
Are there any user-facing changes?
No.