Add TakeSlices for fixed-size-list take#8674
Open
danking wants to merge 3 commits into
Open
Conversation
Merging this PR will not alter performance
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
0908aec to
a039028
Compare
Introduce a lazy TakeSlices array for ordered child ranges, wire FixedSizeList take to emit element ranges, and add a primitive child execution kernel for contiguous range copies. Expand FSL take benchmarks and cover TakeSlices edge cases, nullable validity, generic slice-based execution, and nullable FSL take with nullable indices. Signed-off-by: "Daniel King" <dan@spiraldb.com> Signed-off-by: Daniel King <dan@spiraldb.com>
a039028 to
949cfcb
Compare
Refactor fixed-size-list take around structural cases, tighten TakeSlices validation, and extend edge-case coverage. Also document the local-reasoning guideline that would have avoided threading fallback state through the main path. Signed-off-by: "Daniel King" <dan@spiraldb.com> Signed-off-by: Daniel King <dan@spiraldb.com>
Replace ambiguous ordered-range wording with caller-provided sequence terminology so the API docs do not imply sorted or disjoint ranges. Signed-off-by: "Daniel King" <dan@spiraldb.com> Signed-off-by: Daniel King <dan@spiraldb.com>
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.
The key issue here is that
fixed_size_list.take(indices)explodes the indices into one index per list element. For a fixed size list of length 4096, this means the number of take indices expands by three orders of magnitude. Moreover, the take kernel must either naively copy each index separately or reconstruct the fact that these are actually slices so that it can use copy_from_slice.Concretely, for a
FixedSizeList<100, u8>array, this:becomes:
My new benchmarks make clear that using
takewith these indices on a canonical elements array (implemented here) is much slower than using a sequence ofoutput.extend_from_slice(buffer[...])(implemented here).This is a table of results for
FixedSizeList<N, f16>per-index / take_slicesCodex:
Summary
TakeSlicesArrayas a lazy ordered-range selection over one child.FixedSizeListtake through ordered element ranges viatake_slices, leaving child encodings responsible for optimization.TakeSlicesExecutekernel that copies each requested range directly from the primitive slice.take_fslbenchmarks across element byte widths and forced f16 strategy comparisons.Correctness and Coverage
TakeSlicesvalidates all public construction ranges as non-empty and in-bounds.TakeSlicesexecution repeatedly slices the child and appends each range; it does not require a canonical child up front.TakeSlices, nullable primitive validity, scalar/validity access, generic encoded-child fallback, nullable encoded-child fallback, and nullable FSL take with nullable indices.Validation
cargo +nightly fmt --allcargo test -p vortex-array take_slicescargo test -p vortex-array fixed_size_list::tests::takecargo check -p vortex-array --all-targetscargo clippy --all-targets --all-featuresgit diff --cached --check