Skip to content

Reduce lazy masks into arrays with all-valid metadata - #10016

Merged
connortsui20 merged 3 commits into
developfrom
ct/all-valid-mask-reduction
Sep 24, 2026
Merged

connortsui20 merged 3 commits into
developfrom
ct/all-valid-mask-reduction

Conversation

@connortsui20

@connortsui20 connortsui20 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Allows lazy masks to attach directly as validity when an encoding can inspect validity through metadata and the input is AllValid or NonNullable. Array-backed validity and encodings that have not opted in retain the existing lazy-mask fallback.

The reduction rule, in pseudocode, is:

Mask(Array(values, validity = AllValid), m)
    -> Array(values, validity = m)

Mask(Array(values, validity = NonNullable), m)
    -> Array(values, validity = m)

This applies when the input encoding opts into VALIDITY_IS_METADATA_ONLY and supports mask reduction. m is a non-nullable Boolean array with the same length as the input, and it may be lazy. The reduction reuses the values and attaches m as validity without executing it. The output dtype is nullable.

The identity is AllValid AND m = m, so no intermediate validity array is needed.

Changes

Adds MaskReduce::VALIDITY_IS_METADATA_ONLY, defaulting to false, and enables it for Boolean, primitive, decimal, string, list, struct, map, and ByteBool encodings. String, decimal, and list reducers preserve existing buffers and children when rebuilding. List-view masking also preserves its metadata without revalidating the zero-copy flag.

Two focused tests cover direct attachment to an all-valid primitive array and the fallback for array-backed validity, including an all-true bitmap. Existing constant-mask tests remain unchanged, and all tests stay inline. The Boolean device-buffer fix landed in #10018.

Validation before the rebase: 168 focused comparison, mask, and RowFn tests passed on the combined stack through #9979, along with cargo clippy -p vortex-array --all-targets --all-features -- -D warnings. The rebase preserves this PR's patches. Tests, formatting, and benchmarks were not rerun locally after the rebase.

@connortsui20
connortsui20 added this pull request to stack #10017 September 23, 2026 20:46
@codspeed

codspeed Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 4 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.

⚠️ 3 benchmarks measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. These results are not comparable, so they count as unchanged.

Preventing compiler optimizations

⚡ 12 improved benchmarks
❌ 4 regressed benchmarks
✅ 2160 untouched benchmarks
⏩ 385 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation take_chunked_fsl_sorted[32, 64] 195.7 µs 269.6 µs -27.42%
❌ WallTime decode_avx2[8192, (Inline, OneNullInEight)] 86 µs 104.7 µs -17.86%
❌ WallTime filtered_owned_i64_avx512[OneNullInEight] 22.2 µs 26.2 µs -15.14%
❌ WallTime filtered_owned_i64_avx2[OneNullInEight] 22 µs 25.5 µs -13.88%
⚡ WallTime deferred_bool_avx2[16384, (ConstantLhs, PartialAccepted)] 205.8 µs 33.2 µs ×6.2
⚡ WallTime deferred_bool_avx512[16384, (ConstantLhs, PartialAccepted)] 206.2 µs 38.2 µs ×5.4
⚡ WallTime deferred_bool_neon[16384, (ConstantLhs, PartialAccepted)] 169.5 µs 54.3 µs ×3.1
⚡ WallTime deferred_bool_avx2[16384, (Columns, PartialAccepted)] 109.8 µs 42.2 µs ×2.6
⚡ WallTime deferred_bool_avx512[16384, (ConstantLhs, NullOnlyFailure)] 470.8 µs 286.3 µs +64.45%
⚡ WallTime deferred_bool_avx2[16384, (ConstantLhs, NullOnlyFailure)] 454.5 µs 281.4 µs +61.5%
⚡ Simulation take_fsl_f16_force_per_index[256, 10] 57 µs 38.8 µs +46.85%
⚡ WallTime mul_u64_nonnull_neon 40.4 µs 29.1 µs +38.76%
⚡ WallTime deferred_bool_neon[16384, (ConstantLhs, NullOnlyFailure)] 478.6 µs 377.5 µs +26.79%
⚡ WallTime deferred_bool_avx2[16384, (Columns, NullOnlyFailure)] 344.3 µs 278.7 µs +23.53%
⚡ WallTime multiply_shapes_neon[(32768, PerRowPerRow)] 39 µs 32.7 µs +19.03%
⚡ WallTime mul_i64_nonnull_neon 38.9 µs 32.9 µs +18.38%
⚠️ Simulation fixed_16_advancing_ptr_safe[100] < 1 ns < 1 ns N/A
⚠️ Simulation preverify_advancing_ptr_unchecked[1000] < 1 ns < 1 ns N/A
⚠️ Simulation preverify_advancing_ptr_unchecked[10000] < 1 ns < 1 ns N/A

Tip

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


Comparing ct/all-valid-mask-reduction (a8d283b) with develop (26231bb)2

Open in CodSpeed

Footnotes

  1. 385 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. ↩

  2. No successful run was found on develop (da48008) during the generation of this report, so 26231bb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@connortsui20
connortsui20 force-pushed the ct/all-valid-mask-reduction branch from 774f3e3 to 94701b5 Compare September 23, 2026 21:01
@connortsui20
connortsui20 removed this pull request from stack #10017 September 23, 2026 21:02
@connortsui20 connortsui20 changed the title Reduce lazy masks into all-valid Boolean and primitive arrays Reduce lazy masks into arrays with all-valid metadata Sep 23, 2026
@connortsui20
connortsui20 changed the base branch from develop to ct/bool-mask-buffer-handle September 23, 2026 21:02
@connortsui20
connortsui20 added this pull request to stack #10019 September 23, 2026 21:02
@connortsui20
connortsui20 force-pushed the ct/all-valid-mask-reduction branch from 94701b5 to 1ed352c Compare September 23, 2026 21:06
@connortsui20 connortsui20 added the changelog/performance A performance improvement label Sep 23, 2026
@connortsui20
connortsui20 marked this pull request as ready for review September 23, 2026 21:09
Comment thread vortex-array/src/scalar_fn/fns/mask/kernel.rs Outdated
@connortsui20
connortsui20 removed this pull request from stack #10019 September 23, 2026 21:19
@connortsui20
connortsui20 force-pushed the ct/all-valid-mask-reduction branch from 1ed352c to 2c3bd7f Compare September 23, 2026 21:19
@connortsui20
connortsui20 added this pull request to stack #10021 September 23, 2026 21:19
@connortsui20
connortsui20 removed this pull request from stack #10021 September 23, 2026 21:23
@connortsui20
connortsui20 changed the base branch from ct/bool-mask-buffer-handle to develop September 23, 2026 21:23
@connortsui20
connortsui20 force-pushed the ct/all-valid-mask-reduction branch from 2c3bd7f to 0c55830 Compare September 23, 2026 21:23
@connortsui20
connortsui20 changed the base branch from develop to ct/bool-mask-buffer-handle September 23, 2026 21:23
@connortsui20
connortsui20 added this pull request to stack #10022 September 23, 2026 21:23
Base automatically changed from ct/bool-mask-buffer-handle to develop September 23, 2026 21:39
@connortsui20
connortsui20 force-pushed the ct/all-valid-mask-reduction branch from ec0a8a9 to d09f2a1 Compare September 23, 2026 21:39
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 force-pushed the ct/all-valid-mask-reduction branch from d09f2a1 to a8d283b Compare September 23, 2026 21:45
@connortsui20
connortsui20 merged commit ad6ee9d into develop Sep 24, 2026
118 of 123 checks passed
@connortsui20
connortsui20 deleted the ct/all-valid-mask-reduction branch September 24, 2026 02:36
///
/// Enables lazy masks on all-valid inputs. Only opt in when `array.validity()` cannot read
/// buffers or execute children, including for nullable inputs.
const VALIDITY_IS_METADATA_ONLY: bool = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be on the main vtable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

honestly I would like that

connortsui20 added a commit that referenced this pull request Sep 24, 2026
Depends on #10016.

RowFn output payloads bypass the execution allocator. This change
allocates them directly through `ctx.allocator()` across owned,
deferred-retry, selected, filtered, constant, and sink execution, while
preserving zero-copy primitive publication and empty-output paths.

`OutputElement` chooses its collection storage through an associated
buffer type and an allocation hook. The executor writes through
`OutputBuffer` slots, and the buffer implementation constructs the
array. Vortex primitive and Boolean implementations use `BufferMut`,
while scalar and fixed-size-list sinks use the same storage contract.
UTF-8 descriptors, external bytes, and polygon payloads also use the
execution allocator. Physical sink parameters remain separate from
allocation resources.

Regressions check ownership of returned payloads using canonical inputs
prepared before allocation tracking, including a context override,
constant UTF-8 output, retry execution, and zero-copy reuse. A
zero-sized output with `Vec` storage exercises the owned execution paths
without requiring `BufferMut`. Boolean collector selection is preserved.

The Boolean dense-retry path from merged #9986 also uses the execution
allocator, with coverage in the existing packed-output allocator test.

Validation before the rebase: 168 focused comparison, mask, and RowFn
tests passed on the combined stack through #9979, along with `cargo
clippy -p vortex-array --all-targets --all-features -- -D warnings`.
Tests, formatting, and benchmarks were not rerun locally after the
rebase.

---------

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants