Skip to content

Optimize list_contains with prepared constant sets - #10052

Open
robert3005 wants to merge 1 commit into
developfrom
claude/friendly-knuth-dj6ed1-list-contains
Open

robert3005 wants to merge 1 commit into
developfrom
claude/friendly-knuth-dj6ed1-list-contains

Conversation

@robert3005

@robert3005 robert3005 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Replace constant-set membership comparison/OR chains with prepared, single-pass probes

@codspeed

codspeed Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 10 benchmarks

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 12 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 5 improved benchmarks
❌ 10 regressed benchmarks
✅ 2168 untouched benchmarks
⏩ 359 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation optimize_lookup_predicate[ids=192, shape=in_list] 50.4 µs 75.5 µs -33.2%
❌ Simulation optimize_lookup_predicate[ids=128, shape=in_list] 51.1 µs 72.9 µs -29.97%
❌ Simulation optimize_lookup_predicate[ids=64, shape=in_list] 50.9 µs 70.3 µs -27.6%
❌ WallTime mul_u64_nonnull_neon 28.7 µs 39.2 µs -26.64%
❌ Simulation optimize_lookup_predicate[ids=16, shape=in_list] 51.7 µs 69.1 µs -25.1%
❌ Simulation optimize_lookup_predicate[ids=256, shape=in_list] 79.4 µs 104.7 µs -24.2%
❌ Simulation optimize_lookup_predicate[ids=1, shape=in_list] 74.8 µs 89.6 µs -16.46%
❌ WallTime multiply_shapes_neon[(32768, PerRowPerRow)] 32.7 µs 38.1 µs -14.15%
❌ WallTime mul_i64_nonnull_neon 32.7 µs 38.1 µs -14.08%
❌ Simulation or_true_constant 18.5 µs 20.6 µs -10.2%
⚡ Simulation i64_random_chunked[256] 15,817.7 µs 171.1 µs ×92
⚡ Simulation utf8_random[256] 13,524.8 µs 355.5 µs ×38
⚡ Simulation i64_random[256] 4,360.6 µs 131.1 µs ×33
⚡ Simulation nested_list_random[32] 6.7 ms 1 ms ×6.7
⚡ WallTime bitpack_blocked_compress_avx512 5.6 µs 4.7 µs +18.98%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/friendly-knuth-dj6ed1-list-contains (79947bc) with develop (731a231)

Open in CodSpeed

Footnotes

  1. 359 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@robert3005
robert3005 removed this pull request from stack #10055 September 25, 2026 14:05
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch from f1eea0e to ef75b12 Compare September 25, 2026 14:06
@robert3005
robert3005 changed the base branch from develop to rk/list-contains-sql-null-semantics September 25, 2026 14:06
@robert3005
robert3005 added this pull request to stack #10058 September 25, 2026 14:06
@robert3005 robert3005 changed the title Optimise list_contains to avoid chained ORs and add option to follow sql null semantics Optimize list_contains with prepared constant sets Sep 25, 2026
@robert3005
robert3005 removed this pull request from stack #10058 September 25, 2026 14:09
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch from ef75b12 to f350f7b Compare September 25, 2026 14:09
@robert3005
robert3005 changed the base branch from rk/list-contains-sql-null-semantics to rk/list-contains-benchmarks September 25, 2026 14:09
@robert3005
robert3005 added this pull request to stack #10061 September 25, 2026 14:09
@joseph-isaacs

joseph-isaacs commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

How do i extend this to work for new custom kernels?

I really think we want to make probe an array to allow reduce/execute rules?

@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch 2 times, most recently from 3e6c3cb to 12f4b8f Compare September 25, 2026 16:28
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch from 12f4b8f to 4b5ce4a Compare September 25, 2026 17:10
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch from 4b5ce4a to 74eda6a Compare September 25, 2026 17:26
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch 2 times, most recently from ab3ce3b to fd2586b Compare September 28, 2026 20:43
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch 3 times, most recently from cfed2d7 to b888b1b Compare September 28, 2026 22:28
Comment thread vortex-array/src/arrays/constant/vtable/canonical.rs Outdated
Comment thread vortex-array/src/arrays/constant/vtable/canonical.rs Outdated
Comment thread vortex-array/src/arrays/constant/vtable/canonical.rs
Comment thread vortex-array/src/scalar_fn/fns/list_contains/prepared/array.rs Outdated
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch from 5bea57b to 6207abb Compare September 29, 2026 19:12
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch 2 times, most recently from 159aaff to 77f114d Compare September 29, 2026 21:09
parent: ArrayView<'_, ScalarFn>,
child_idx: usize,
) -> VortexResult<Option<ArrayRef>> {
if parent.scalar_fn().is::<ListContains>() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a hack, we essentially have common setup we would like to share across chunks, if we just dispatch over each chunk there's no place to store the shared state

Base automatically changed from rk/list-contains-benchmarks to develop October 5, 2026 12:22
Comment thread encodings/runend/src/compute/list_contains.rs Outdated
`list_contains(lit([...]), needles)`, the `IN` shape, built one `Eq` per
set element and OR-reduced them: a pass over the needles per element.
The constant list is now prepared once into a probe structure and every
needle is probed in a single pass.

The probe adapts to the elements: integers, and floats by their bit
patterns, use a bitmap over a dense span or a sorted slice; decimals
their unscaled values the same way; UTF-8 and binary a table keyed by
the view for short values and by the bytes for long ones; nested rows a
sorted index over the row comparator.

A literal list becomes a `PreparedSetLiteral` when the expression is
optimized, so every batch probes one shared set; a constant list in an
array tree becomes a `PreparedSetArray` on optimization. Reduce rules
for `Dict`, `RunEnd`, `Chunked` and `Sequence` push the function into
their values or chunks with slices of that array, so all share the set.

The list-column-against-needle-column case, previously unsupported,
gathers each list's elements next to its row's needle for one equality.
A list scalar's elements are written straight from their values rather
than through a scalar per element.

The `list_contains_set` benchmark covers integer, string and nested
sets over flat and chunked needles.

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TAbnsC5szeE4SiAmR3FciD
@robert3005
robert3005 force-pushed the claude/friendly-knuth-dj6ed1-list-contains branch from 4677d2e to 79947bc Compare October 9, 2026 21:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants