Skip to content

Skip codegen of unreachable type dispatch arms - #10740

Open
robert3005 wants to merge 1 commit into
developfrom
rk/size-unreachable-dispatch-arms
Open

robert3005 wants to merge 1 commit into
developfrom
rk/size-unreachable-dispatch-arms

Conversation

@robert3005

@robert3005 robert3005 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

A const condition removes the unreachable arms before codegen in three places:

  • check_decimal_identical dispatched on the lhs storage type, the rhs storage type and their widest type. The two distinct inputs fix the widest type, so only 30 of 216 arms can run.
  • widened_buffer::<W> is only called for storage types narrower than W (all callers pass the wider of two inputs), and the narrowing branch of converted_buffer::<W> only runs for storage types wider than W. Only 15 of 36 arms of each can run.
  • The bit-packed widening cast compiled all 64 integer pairs, but only widening pairs reach the kernel.

Bit-packing rejects negative values, so sign extension of a packed value is the same as zero extension. The bit-packed cast now views a signed source as unsigned (the packed buffer is shared and the patch values are reinterpreted) and reinterprets the result to the target type. Signed and unsigned casts of the same widths share one kernel, so the cast compiles 6 kernels instead of 18 reachable ones.

release __text (macOS arm64) before after
vortex-array 14,023,548 B 13,933,616 B (-90 KB)
vortex-fastlanes 4,442,156 B 4,331,764 B (-110 KB)

Three dispatches compiled kernels for type combinations that an
invariant makes unreachable:

- check_decimal_identical dispatched on lhs, rhs and their widest
  type, but the widest type is fixed by the two distinct inputs.
- widened_buffer is called only for storage types narrower than W,
  and the narrowing branch of converted_buffer only for wider ones.
- The bit-packed widening cast compiled every integer pair, but only
  widening pairs reach the kernel.

A const condition now removes the other arms before codegen. Also,
bit-packing rejects negative values, so the bit-packed cast now views
signed sources as unsigned and reinterprets the result. Signed and
unsigned casts of the same widths share one kernel.

Release __text: vortex-array 14,023,548 -> 13,933,616 bytes (-90 KB),
vortex-fastlanes 4,442,156 -> 4,331,764 bytes (-110 KB).

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robert3005 robert3005 added the changelog/chore A trivial change label Oct 23, 2026
@codspeed

codspeed Bot commented Oct 23, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

3 warnings, 1 note

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ Unable to measure the execution of 1 benchmark

This benchmark measured no execution time, so its result is not comparable and counts as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

⚠️ 20 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 40 benchmarks have no flamegraph

The flamegraph wasn't generated: the symbols of the profiling trace could not be resolved, because no information about the language frames was collected.

See affected benchmarks

⚡ 8 improved benchmarks
❌ 1 regressed benchmark
✅ 2399 untouched benchmarks
⏩ 12 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Walltime threshold_avx2[80] 2.6 µs 2.9 µs -10.54%
⚡ Walltime filter_neon[8] 1,997 ns 924 ns ×2.2
⚡ Walltime threshold_neon[8] 2.6 µs 1.3 µs +96.65%
⚡ Walltime filter_neon[64] 2.5 µs 1.8 µs +39.35%
⚡ Walltime threshold_neon[64] 3.5 µs 2.6 µs +36.62%
⚡ Walltime threshold_neon[80] 4.6 µs 3.4 µs +34.78%
⚡ Walltime filter_neon[80] 3.4 µs 2.7 µs +26.32%
⚡ Walltime decode_chunked_neon[i64, 524288] 15.7 µs 13.4 µs +17.34%
⚡ CPU Simulation or_true_constant 20.8 µs 18.8 µs +10.53%

Tip

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


Comparing rk/size-unreachable-dispatch-arms (dd90465) with develop (c750fbd)

Open in CodSpeed

Footnotes

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

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/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant