Repository navigation
GH-35126: [C++] Reuse full plain chunks in ChunkedArray::Slice - #55719
Draft
Aurantium-47 wants to merge 1 commit into
Draft
Aurantium-47 wants to merge 1 commit into
Aurantium-47 wants to merge 1 commit into
Conversation
Reuse existing Array wrappers for complete aligned plain chunks. Retain the slicing path for boundaries, statistics, nested data, dictionaries and extension arrays.
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.
Rationale for this change
Addresses #35126. Repeatedly slicing a table with many chunks recreates Array and ArrayData wrappers for chunks that are included in full. Reusing those wrappers reduces this overhead for full aligned plain chunks; their payload buffers were already zero-copy.
What changes are included in this PR?
In
ChunkedArray::Slice, reuse the existing Array wrapper when a chunk is included in full at an aligned boundary, has no statistics, child data or dictionary, and is not an extension array. Boundary chunks, statistics-bearing chunks, nested arrays, dictionary arrays and extension arrays retain the previous slicing path.Add regression tests for wrapper reuse across aligned plain chunks (including an empty chunk and a chunk with a nonzero logical offset), partial boundary values, and dropping statistics through the existing path.
Are these changes tested?
Prior local validation used this exact patch at upstream main
cba325ed67235fe16c307b9cf974a54433d9f9c7:arrow-table-testlinked to the locally builtlibarrow.so.2700: 213/213 passed, including 16/16 TestChunkedArray.27.0.0-SNAPSHOTlibrary measured median time from 0.869 s to 0.114 s for a synthetic repeated shrinking-tail workload with 1,000 chunks × 1,024 rows × 10 columns. 692 slice comparisons and additional guard/lifetime checks passed. These timings describe that synthetic workload only.Submission checks also passed:
git apply --check,git diff --check, exact changed-file scope, and byte-for-byte agreement between the applied diff and the verified patch (SHA-256f22fe8d566c73b9c587587c145629b85a38c39ad9e9ef1033ba8cf34bf5c1151). Current upstream main still matches the tested commit. The native tests and benchmark were completed before this submission; they were not rerun during submission.Are there any user-facing changes?
Full aligned plain chunks now preserve Array and ArrayData pointer identity with the input instead of creating new wrappers. Keeping the slice alive can therefore extend the lifetime of the original Array and ArrayData wrappers, and their metadata objects are shared. Payload buffers were already shared by the previous zero-copy path. The guarded cases listed above retain their previous behavior.
Was AI used for this PR?
ChatGPT assisted the implementation and local testing. Codex prepared this PR description and submitted this draft.