refactor(array): canonicalize chunked structs and FSLs through the builder [builders-child-stack] - #8967
Conversation
Merging this PR will degrade performance by 31.27%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
afed52f to
79f350a
Compare
79f350a to
1145029
Compare
…ilder `pack_struct_chunks` and `swizzle_fixed_size_list_chunks` existed because `append_to_builder` used to decode a builder's children: without them, canonicalizing a `ChunkedArray` would concatenate every chunk's children instead of reusing them. Their doc comments describe what the builders now do on their own, so both are dead weight. Route both dtypes through the generic builder path. `ListArray` keeps its swizzle for now — that one also allocates its offsets and sizes through the session allocator, which the builders cannot yet do. Signed-off-by: Claude <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <robert@spiraldb.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1145029 to
8f39b06
Compare
Rationale for this change
Stacked on #8966 → #8964 → #9064 → #9046 — review those first. This is the payoff for the rest of the stack.
ChunkedArray's_canonicalizecarried four hand-written special cases plus a genericappend_to_builderfallback. Two of them existed purely becauseappend_to_builderused to decode a builder's children; their doc comments say so:pack_struct_chunks— "a singleStructArray, where the data for each field is aChunkedArray"swizzle_fixed_size_list_chunks— "reuse the chunks'elementschildren directly as the chunks of a combinedelementsarray without copying"That is what
ChildBuilderdoes now, so both are dead weight — an extra path to keep correct for a result the generic path already produces.What changes are included in this PR?
DType::StructandDType::FixedSizeListfall through to the builder, and both helpers are deleted. Nothing has to be configured for this to work: since #8964 a nested builder keeps every appended chunk however short, which is the behaviour the swizzles hand-rolled. An earlier revision of this PR calledbuilder.set_min_chunk_len(0)here to opt out of a length threshold that no longer exists.I verified the shapes match before deleting anything. A
tree_displayprobe over chunked struct / list / FSL inputs produces byte-identical trees on both paths for chunks of 200 rows — struct field isvortex.chunked(i32, len=400)with two chunks, FSLelementslikewise. Two newrstestcases lock that in using chunks of one row.What is not included
ListArraykeepsswizzle_list_chunks. The builder produces the same shape —is_zero_copy_to_list: trueand all — but the swizzle also allocates its offsets and sizes throughctx.allocator(), and builders are not allocator-aware:builder_with_capacity_intakes aHostAllocatorRefand discards it (let _allocator = allocator;).list_canonicalize_uses_memory_session_allocatorcatches exactly this. Making it work means threading an allocator throughBufferMutinvortex-buffer, which has none today — a bigger and separate piece of work than this stack, so the list swizzle stays until someone does it.pack_variant_chunksstays too:builder_with_capacityisunimplemented!()forDType::Variant.StructArray::try_concatis now unused in-tree. It ispub, and a useful helper in its own right, so I left it — removing public API seemed like a separate call for a reviewer to make rather than something to slip into this PR.What APIs are changed? Are there any user-facing changes?
No API changes, and no observable difference: the generic builder path preserves every chunk boundary, which is exactly what the swizzles did.
Checks
cargo nextest run --workspace— 7168 passed, 560 skippedcargo clippy --all-targets --all-features— cleancargo +nightly fmt --all --check— cleanGenerated by Claude Code
Stacked PR Chain: builders-child-stack
Generated by Claude Code