Skip to content

Map constant RowFn inputs directly - #9628

Merged
connortsui20 merged 1 commit into
developfrom
ct/row-fn-constant-sources
Aug 26, 2026
Merged

connortsui20 merged 1 commit into
developfrom
ct/row-fn-constant-sources

Conversation

@connortsui20

@connortsui20 connortsui20 commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Summary

#9620 lets Boolean output collect results directly into a packed bit buffer, but only when every input varies by row. A RowFn constant is stored as one decoded value instead of a row_count-element view, so one constant input still forces an intermediate Vec<bool>:

before: (column, column)   -> BitBuffer
        (column, constant) -> Vec<bool> -> BitBuffer

after:  either input shape -> BitBuffer

This PR does not add constant handling. It makes the direct output collector usable with the constant handling RowFn already has. Depends on #9620.

Changes

Adds a private indexed source over decoded ArgColumns. Each argument reads either row index or its single decoded constant, while the source still reports the logical batch length expected by OutputElement::build_from.

The row-or-constant choice remains visible to the optimizer before traversal, which preserves direct packed Boolean stores. Tests cover both constant positions, all-constant input, and nullary execution.

API Changes

Clarifies that InputElement::view must produce the same row values as InputElement::get for every addressable index.

@codspeed

codspeed Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 52.4%

⚠️ 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.

⚡ 1 improved benchmark
✅ 2111 untouched benchmarks
🆕 18 new benchmarks
⏩ 106 skipped benchmarks1
🗄️ 4 archived benchmarks run2

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ WallTime arrow_checked_add_u32_neon[16384] 20.3 µs 13.3 µs +52.4%
🆕 WallTime infallible_bool_neon[i32, ConstantPerRow] N/A 4.2 µs N/A
🆕 WallTime infallible_bool_neon[i32, PerRowConstant] N/A 4.3 µs N/A
🆕 WallTime infallible_bool_neon[i32, PerRowPerRow] N/A 3.7 µs N/A
🆕 WallTime infallible_bool_neon[i64, ConstantPerRow] N/A 5.6 µs N/A
🆕 WallTime infallible_bool_neon[i64, PerRowConstant] N/A 5.7 µs N/A
🆕 WallTime infallible_bool_neon[i64, PerRowPerRow] N/A 5.7 µs N/A
🆕 WallTime infallible_bool_avx2[i32, ConstantPerRow] N/A 3.4 µs N/A
🆕 WallTime infallible_bool_avx2[i32, PerRowConstant] N/A 3.4 µs N/A
🆕 WallTime infallible_bool_avx2[i32, PerRowPerRow] N/A 2.8 µs N/A
🆕 WallTime infallible_bool_avx2[i64, ConstantPerRow] N/A 11.4 µs N/A
🆕 WallTime infallible_bool_avx2[i64, PerRowConstant] N/A 11.4 µs N/A
🆕 WallTime infallible_bool_avx2[i64, PerRowPerRow] N/A 10.3 µs N/A
🆕 WallTime infallible_bool_avx512[i32, ConstantPerRow] N/A 2.9 µs N/A
🆕 WallTime infallible_bool_avx512[i32, PerRowConstant] N/A 2.8 µs N/A
🆕 WallTime infallible_bool_avx512[i32, PerRowPerRow] N/A 2.3 µs N/A
🆕 WallTime infallible_bool_avx512[i64, ConstantPerRow] N/A 3.9 µs N/A
🆕 WallTime infallible_bool_avx512[i64, PerRowConstant] N/A 3.8 µs N/A
🆕 WallTime infallible_bool_avx512[i64, PerRowPerRow] N/A 3.8 µs N/A

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ct/row-fn-constant-sources (52c4e85) with develop (0a128b6)3

Open in CodSpeed

Footnotes

  1. 106 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. 4 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them. ↩

  3. No successful run was found on develop (beb7c15) during the generation of this report, so 0a128b6 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/row-fn-constant-sources branch 2 times, most recently from 08450db to d979a9b Compare August 25, 2026 21:34
@connortsui20
connortsui20 marked this pull request as ready for review August 26, 2026 14:36
Base automatically changed from ct/row-fn-bool-output to develop August 26, 2026 15:13
connortsui20 added a commit that referenced this pull request Aug 26, 2026
## Summary

- Tracking Issue: #9128

Lets infallible RowFn output types collect directly from a validated row
source. Boolean output uses `BitBuffer::collect_bool` instead of
materializing an intermediate `Vec<bool>`.

This is the first layer of the stack. Constant inputs follow in #9628.

## Changes

Adds a default `OutputElement::build_from` implementation and a Boolean
override that writes the packed bitmap. A dedicated
`execute_owned_infallible` route uses it when all inputs have validated
non-constant views. Constant and valid-only execution keep their
existing `Vec` paths.

Tests cover packed values and nullability, bitmap word boundaries,
nullary input, and skipped invalid rows. A focused Divan benchmark
covers `i32` and `i64` Boolean output with varying inputs and both
constant orientations.

With rustc 1.98.0 and LLVM 22.1.8 targeting x86-64 AVX2 with 16 CGUs and
no LTO, the varying-input loop now emits vector compares, `vpmovmskb`,
and a direct packed-word store. The `develop` control writes unpacked
Boolean bytes to a temporary vector before packing them.

## API Changes

Adds `OutputElement::build_from`. Implementations must evaluate every
source row exactly once in order, return the same values as `build`, and
cannot introduce value-dependent errors or panics.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 force-pushed the ct/row-fn-constant-sources branch from d979a9b to a254aaf Compare August 26, 2026 15:13
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 force-pushed the ct/row-fn-constant-sources branch from a254aaf to 52c4e85 Compare August 26, 2026 17:07
@connortsui20
connortsui20 merged commit 42a5d3b into develop Aug 26, 2026
80 checks passed
@connortsui20
connortsui20 deleted the ct/row-fn-constant-sources branch August 26, 2026 17:25
connortsui20 added a commit that referenced this pull request Aug 27, 2026
## Summary

- Tracking Issue: #9128

`RowFn` handles constant inputs so row kernels do not need separate
execution paths for each input shape. #9628 adds an indexed source for
infallible execution, but fallible `execute_owned` still uses a separate
loop whenever any input is constant. That loop selects between row and
constant values on every iteration, duplicating the traversal and hiding
the fixed batch input shape from LLVM.

Depends on #9628.

## Changes

Extends the decoded indexed source to fallible `execute_owned` calls.
Each source validates its decoded length and fixes its row-or-constant
behavior before traversal, allowing every input shape to use
`map_checked_into` without changing output initialization or deferred
failure handling.

This removes the separate `LaneZip` branch. Optimized x86 IR preserves
the vector loop while reducing the focused deferred Boolean executor by
27% and the deferred `i64` executor by 19%, with the same bounds-panic
sites. Tests cover a constant left-hand input, and the focused benchmark
covers varying inputs and both partial-constant orientations.

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.

2 participants