Extend MaskValuesRef to filter execution - #9542
Conversation
Merging this PR will improve performance by 12.82%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | cold_misaligned[(16, 64)] |
429.3 µs | 380.5 µs | +12.82% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ct/mask-value-ref (8eef241) with develop (68cdf00)
Footnotes
-
1470 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. ↩
Filter execution passes shared mask handles through private helpers and clones them to rebuild masks for child arrays. Spell those boundaries as MaskValuesRef instead of Arc<MaskValues> or MaskValues. This keeps ownership visible at each call site and avoids dereferencing through the handle. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S6E8CET6sGJwL2VhFAoLig
Filter execution matched the mask twice: `execute_filter_fast_paths` resolved the all-true and all-false cases through `true_count`, then the vtable re-matched for the `MaskValuesRef` behind an `unreachable!`. Match the mask once in the vtable and pass the true count to the remaining all-null fast path. The DuckDB validity exporter had the same shape, where a `bool` predicate matched the mask and the closure that built `ValidityData` matched it again behind an `unreachable!`. Return the data from one match instead. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S6E8CET6sGJwL2VhFAoLig
7e174ce to
7d6be0f
Compare
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
| if let Some(canonical) = execute_filter_fast_paths(array.as_view(), ctx)? { | ||
| return Ok(ExecutionResult::done(canonical)); | ||
| } |
There was a problem hiding this comment.
moving logic around to keep related code closer
Summary
Extends
MaskValuesRefthrough filter execution and the remaining private helpers that receive a shared mask handle.Also cleans up some code around the changes.
Changes
Replaces
&Arc<MaskValues>and private&MaskValuesparameters with&MaskValuesRef. Matches selection masks once in theFiltervtable and DuckDB validity exporter, preserving empty-mask precedence and existing behavior.