IN LIST: reinterpret small-width types for bitmap filters#23013
Draft
geoffreyclaude wants to merge 7 commits into
Draft
IN LIST: reinterpret small-width types for bitmap filters#23013geoffreyclaude wants to merge 7 commits into
geoffreyclaude wants to merge 7 commits into
Conversation
10 tasks
cc752d0 to
9925e82
Compare
65f008f to
08fbe39
Compare
Replaces HashSet<u8> with a 32-byte stack-allocated bitmap. Provides O(1) membership testing via bit-shifting, significantly reducing memory overhead and improving cache locality. Triggers for UInt8 arrays.
Implements an 8 KB heap-allocated bitmap for UInt16. Maintains O(1) performance while handling the larger value space. Triggers for UInt16 arrays.
Introduces zero-copy buffer reinterpretation to allow signed integers and other 1 or 2-byte primitive types (e.g. Float16) to use the high-performance bitmap filters. Triggers for all types with 1-byte or 2-byte width.
08fbe39 to
1db5627
Compare
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
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?
INperformance with specialized implementations #19390.Rationale for this change
#23011 and #23012 add bitmap lookups for unsigned 1-byte and 2-byte integers, and #23035 unifies those concrete filters behind one shared bitmap implementation. This PR lets other same-width primitive types reuse those same bitmaps without copying or converting the values.
The key idea is that some types have different meanings but the same physical shape in memory. For example:
UInt8stores one byte.Int8also stores one byte.UInt16stores two bytes.Int16also stores two bytes.The bitmap only cares about the exact bits. So an
Int8value can be viewed as its one-byte bit pattern and checked with theUInt8bitmap. No new array is allocated and the underlying Arrow value buffer is shared.That is what “zero-copy reinterpretation” means here: keep the same bytes, but use a lookup filter whose storage type matches the byte width.
What changes are included in this PR?
Are these changes tested?
Yes.
cargo fmt --allcargo test -p datafusion-physical-expr reinterpreted_bitmap_handles_signed_boundaries_and_slices --libcargo test -p datafusion-physical-expr test_in_list_from_array_type_combinations --libcargo test -p datafusion-physical-expr in_list_int_types --libcargo test -p datafusion-physical-expr test_in_list_dictionary_types --libcargo clippy -p datafusion-physical-expr --all-targets --all-features -- -D warningsAre there any user-facing changes?
No. This is an internal performance optimization only.
Local benchmark snapshot
Benchmark command:
Method: compare adjacent saved baselines using raw Criterion sample minima (
min(time / iters)). Lower is better; changes within +/-5% are treated as noise. These numbers were not rerun after splitting the behavior-preserving bitmap unification into #23035.Compared baselines: #23035 -> #23013
Relevant scope: signed 16-bit reinterpretation rows.
Summary: 6 relevant rows, 6 faster, 0 slower, 0 within +/-5%.
narrow_integer/i16/list=256/match=0%narrow_integer/i16/list=256/match=50%narrow_integer/i16/list=4/match=0%narrow_integer/i16/list=4/match=50%narrow_integer/i16/list=64/match=0%narrow_integer/i16/list=64/match=50%