IN LIST: add branchless filter for small primitive lists#23014
Draft
geoffreyclaude wants to merge 8 commits into
Draft
IN LIST: add branchless filter for small primitive lists#23014geoffreyclaude wants to merge 8 commits into
geoffreyclaude wants to merge 8 commits into
Conversation
10 tasks
428e3cd to
eae4046
Compare
This was referenced Jun 18, 2026
eae4046 to
3e3651b
Compare
3e3651b to
6a1869f
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.
Adds a const-generic unrolled comparison chain that avoids CPU branching. Outperforms hash lookups for very small lists. Triggers for primitives when list size <= 32 (4-byte), 16 (8-byte), or 4 (16-byte).
6a1869f to
d57ed3f
Compare
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
For very small
INlists, building or probing a hash table can be more work than just comparing the input value with each constant.For example, for
x IN (10, 20, 30), the fast path can behave like:Because the list is tiny, those comparisons are cheap. The implementation stores the constants in a fixed-size array and checks them with a compact comparison chain.
“Branchless” here means the comparisons are combined without stopping at the first match. That can be faster for these small fixed-width lists because the CPU gets a predictable sequence of simple operations instead of hash-table setup and probe logic.
Larger primitive lists are left for #23015, where a purpose-built hash lookup becomes the better tradeoff.
What changes are included in this PR?
BranchlessFilterfor small primitiveINlists.IN/NOT INnull behavior as the rest of the stack.Are these changes tested?
Yes.
cargo fmt --all --checkcargo test -p datafusion-physical-expr reinterpreted_ --libcargo test -p datafusion-physical-expr in_list_int_types --libcargo test -p datafusion-physical-expr in_list_float64 --libcargo test -p datafusion-physical-expr in_list_decimal --libcargo test -p datafusion-physical-expr test_in_list_from_array_type_combinations --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.Compared baselines: #23013 -> #23014
Relevant scope: small primitive-list rows.
Summary: 20 relevant rows, 20 faster, 0 slower, 0 within +/-5%.
Largest relevant deltas:
timestamp_ns/small_list/list=4/match=50%f32/small_list/list=4/match=50%primitive/i32/small_list/list=4/match=50%primitive/i64/small_list/list=4/match=50%f32/small_list/list=4/match=0%timestamp_ns/small_list/list=4/match=0%primitive/i32/small_list/list=4/match=0%primitive/i64/small_list/list=4/match=0%primitive/i32/small_list/list=16/match=50%/NOT_INnulls/primitive/i32/small_list/list=16/match=50%/nulls=20%nulls/primitive/i32/small_list/list=16/match=50%/nulls=20%/NOT_INtimestamp_ns/small_list/list=16/match=50%nulls/primitive/i32/small_list/list=16/match=50%/nulls=50%f32/small_list/list=32/match=50%primitive/i64/small_list/list=16/match=50%Full relevant table (20 rows)
f32/small_list/list=32/match=0%f32/small_list/list=32/match=50%f32/small_list/list=4/match=0%f32/small_list/list=4/match=50%nulls/primitive/i32/small_list/list=16/match=50%/nulls=20%nulls/primitive/i32/small_list/list=16/match=50%/nulls=20%/NOT_INnulls/primitive/i32/small_list/list=16/match=50%/nulls=50%primitive/i32/small_list/list=16/match=50%/NOT_INprimitive/i32/small_list/list=32/match=0%primitive/i32/small_list/list=32/match=50%primitive/i32/small_list/list=4/match=0%primitive/i32/small_list/list=4/match=50%primitive/i64/small_list/list=16/match=0%primitive/i64/small_list/list=16/match=50%primitive/i64/small_list/list=4/match=0%primitive/i64/small_list/list=4/match=50%timestamp_ns/small_list/list=16/match=0%timestamp_ns/small_list/list=16/match=50%timestamp_ns/small_list/list=4/match=0%timestamp_ns/small_list/list=4/match=50%