Repository navigation
Fuse primitive encoding chains block by block in the executor - #11533
joseph-isaacs wants to merge 5 commits into
Conversation
The iterative executor descends an encoding tree with ExecuteSlot frames, so when it reaches a leaf the frames on its stack are the parents waiting for that leaf to be canonical. The executor now fuses that chain: the leaf emits blocks of at most 1024 rows (BlockSource), each waiting parent transforms a block (BlockOp), and only the outermost parent writes a full-length buffer. No execute implementation changes; encodings opt in through two defaulted vtable methods, block_source and block_op. Fusion is tried at two points of execute_until: before executing an encoded leaf (after its execute_parent probes, so no kernel is skipped) and when a child becomes canonical below two or more waiting parents. Implemented for Primitive (source), BitPacked (source), FoR (fused unfor_pack source over BitPacked, and a reference-adding op over any child) and ALP (decode and patch op). Disable with ExecutionCtx::with_block_fusion(false) or VORTEX_BLOCK_FUSION=0. Adds encodings/fastlanes/benches/block_fusion.rs comparing fused and level-wise execution on the same arrays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniB9bmdcvP43mdgntV8U Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniB9bmdcvP43mdgntV8U Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Make the fusion contract explicit instead of inferring it from the stack. An encoding asks for its last child with the new ExecutionStep::ExecuteSpine (ExecutionResult::execute_spine, require_spine!), promising that once that child is canonical its execute only transforms the child's values row by row, as its block_op does, and that every other child it needs is already executed. Stack frames record the flag, and the executor only walks and fuses spine frames; frames pushed with ExecuteSlot end a chain. FoR requests its encoded child as its spine. ALP now requests its patches before its encoded child, which it requests as its spine. The single-step executor treats ExecuteSpine like ExecuteSlot. Documents ExecuteSpine and block fusion in the execution internals guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniB9bmdcvP43mdgntV8U Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Emits a vortex_array::block debug event with the outermost encoding, length and chain depth, so benchmark runs can count how often fusion fires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniB9bmdcvP43mdgntV8U Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Benchmarks: TPC-DS SF=10 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (1.003x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.997x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (0.994x ➖, 0↑ 0↓)
duckdb / parquet / ns (0.995x ➖, 0↑ 0↓)
No file size changes detected. |
Polar Signals Profiling ResultsLatest Run
Previous Runs (7)
Powered by Polar Signals Cloud |
Benchmarks: FineWeb NVMe 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.981x ➖, 1↑ 1↓)
datafusion / parquet / ns (1.006x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.005x ➖, 0↑ 0↓)
duckdb / parquet / ns (0.988x ➖, 0↑ 0↓)
No file size changes detected. |
Benchmarks: PolarSignals Profiling 📖Commits: PR datafusion / vortex-file-compressed / ns (0.992x ➖, 1↑ 1↓)
No file size changes detected. |
Benchmarks: TPC-H SF=1 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (1.003x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.996x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.004x ➖, 0↑ 1↓)
duckdb / parquet / ns (1.002x ➖, 0↑ 0↓)
No file size changes detected. |
Benchmarks: TPC-H SF=10 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.991x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.994x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.004x ➖, 0↑ 0↓)
duckdb / parquet / ns (0.998x ➖, 0↑ 0↓)
No file size changes detected. |
Cast: a cast that cannot fail (a lossless primitive conversion that does not drop nullability) now asks for its input as its spine, until the input is columnar, and transforms blocks with a value conversion. Other casts execute as before. ZigZag: execute requests its encoded child as its spine instead of executing it recursively, and decodes blocks of unsigned integers. VTable::block_op now receives the child's dtype, which the executor knows from the frame, so a cast can check it converts losslessly without reading the taken slot. Adds cast and ZigZag cases to the block_fusion benchmark and tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniB9bmdcvP43mdgntV8U Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Benchmarks: TPC-DS SF=1 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.999x ➖, 0↑ 0↓)
datafusion / parquet / ns (1.001x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (0.991x ➖, 1↑ 0↓)
duckdb / parquet / ns (0.997x ➖, 0↑ 1↓)
No file size changes detected. |
Benchmarks: Clickbench on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.990x ➖, 1↑ 0↓)
datafusion / parquet / ns (0.993x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.005x ➖, 0↑ 0↓)
duckdb / parquet / ns (1.012x ➖, 0↑ 0↓)
No file size changes detected. |
Benchmarks: TPC-H SF=1 on S3 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.893x ➖, 4↑ 1↓)
datafusion / parquet / ns (0.918x ➖, 2↑ 0↓)
duckdb / vortex-file-compressed / ns (0.955x ➖, 1↑ 1↓)
duckdb / parquet / ns (0.909x ➖, 2↑ 0↓)
|
Summary
Draft to run the CodSpeed and SQL benchmarks in CI. This revisits the 1024-row streaming idea from #9614, built into the iterative executor instead of a separate recursive vtable path.
The iterative executor descends an encoding tree with
ExecuteSlotframes. When it reaches a leaf, the frames on its stack are the chain of parents waiting for that leaf to be canonical. Level-wise execution writes a full-length buffer at every level of that chain. This PR fuses the chain instead:BlockSource);BlockOp), with intermediates in two L1 scratch buffers used in turn;Changes
ExecutionStep::ExecuteSpine(ExecutionResult::execute_spine,require_spine!). An encoding uses it for the last child itsexecutewaits for. It promises that every other child it needs is already executed, and that once this child is canonical,executeonly transforms the child's values row by row. Frames record the flag, and the executor only fuses through spine frames.Two defaulted vtable methods,
block_sourceandblock_op(slot).block_opmust produce exactly whatexecuteproduces once the slot is canonical. No existingexecuteimplementation changes beyond FoR and ALP requesting their spine.execute_untiltries fusion in two places:execute_parentprobes, so no parent kernel is skipped;A leaf with no block source but a child that is already canonical uses that child as the source, with its own op on top. Anything else falls back to level-wise execution unchanged.
Encodings:
unchecked_unfor_packper chunk. Over any other child it is an add-reference op.map_intolane kernels as level-wise execution.Disable with
ExecutionCtx::with_block_fusion(false)orVORTEX_BLOCK_FUSION=0. Each fused chain logs avortex_array::blockdebug event.Docs:
docs/developer-guide/internals/execution.mdgains a Block Fusion section.Tests
The new tests in
encodings/fastlanes/src/block.rsexecute each tree with fusion on and off and compare the results. They cover:They also count the chains actually fused, so a test can't pass just because fusion never ran.
Local micro benchmark
Source:
encodings/fastlanes/benches/block_fusion.rs, 60 rounds × 100 samples. Speedup is level-wise ÷ fused, paired within each round, on a noisy 4-core VM. FoR(BP) alone fuses nothing and serves as the control.Checks
cargo test -p vortex-array -p vortex-fastlanes -p vortex-alpcargo clippy -p vortex-array -p vortex-fastlanes -p vortex-alp --all-targets --all-features -- -D warningscargo +nightly-2026-11-13 fmton the same cratestypos, docs build, workspace-wide checks.API Changes
vortex_array::blockmodule.ExecutionStep::ExecuteSpine. This breaks exhaustive matches onExecutionStep.ExecutionResult::execute_spineandrequire_spine!.VTable::block_source/VTable::block_opwith defaults.ExecutionCtx::with_block_fusion/block_fusion.Generated by Claude Code