Skip to content

Share FastLanes compare kernels between operators and signedness - #10739

Open
robert3005 wants to merge 2 commits into
developfrom
rk/size-fastlanes-compare-negate
Open

robert3005 wants to merge 2 commits into
developfrom
rk/size-fastlanes-compare-negate

Conversation

@robert3005

@robert3005 robert3005 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Negated operators share kernels. NotEq, Gte and Lte are the inverse of Eq, Lt and Gt, so each pair now uses one set of kernels. When the operator is a negation, stream_compare_fused inverts each 1024-bit output block right after the transpose, while the block is still in cache. This adds 16 word NOTs for each 1024 values. between passes negate = false.

Signed types use the unsigned kernels. Bit-packing rejects negative integers (ensure_non_negative_integers), so packed values of a signed type are never negative.

  • A negative constant compares the same against every packed value as against zero, so the result is constant. It is handled before the fused kernel.
  • Otherwise both sides are non-negative, and the unsigned physical values compare the same as the signed values. The fused kernel now takes function items of the physical type (<T as PhysicalPType>::Physical::is_lt and so on), so signed and unsigned arrays of one width share one set of kernels.

Patches and width 0 still use the exact predicate on the logical type.

vortex-fastlanes release __text (macOS arm64) bytes
develop 4,442,156
negated operators share kernels 3,279,596
+ signed types use unsigned kernels 2,846,252 (-1.60 MB, -36%)

@robert3005 robert3005 added the changelog/chore A trivial change label Oct 23, 2026
The fused bit-packed compare compiled the unpack_cmp kernel for each of
the six compare operators, for every bit width and value type. NotEq,
Gte and Lte are the inverse of Eq, Lt and Gt, so each pair now uses one
kernel. The fused kernel inverts each 1024-bit output block while the
block is still in cache when the operator is a negation. That adds
16 word NOTs for each 1024 values.

The compare sweep tests now check all six operators.

vortex-fastlanes release __text: 4,441,900 -> 3,279,340 bytes
(-1.16 MB).

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robert3005
robert3005 force-pushed the rk/size-fastlanes-compare-negate branch from e21bda4 to ae5c54f Compare October 23, 2026 17:01
Comment on lines +127 to +129
if negate {
out.iter_mut().for_each(|word| *word = !*word);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is the added work of this pr

Bit-packing rejects negative integers, so packed values of a signed
type are never negative. A negative constant compares the same against
every packed value as against zero, and is handled before the fused
kernel. Otherwise both sides are non-negative, and the unsigned
physical values compare the same as the signed values. The fused kernel
now takes function items of the physical type, so signed and unsigned
arrays of one width share one set of unpack_cmp kernels.

vortex-fastlanes release __text: 3,279,596 -> 2,846,252 bytes
(-433 KB).

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robert3005 robert3005 changed the title Share FastLanes compare kernels between negated operators Share FastLanes compare kernels between operators and signedness Oct 23, 2026
@codspeed

codspeed Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

4 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

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

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

ℹ️ 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

⚡ 19 improved benchmarks
❌ 1 regressed benchmark
✅ 2388 untouched benchmarks
⏩ 12 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation test_scan_filter[int] 3.2 ms 3.6 ms -12.67%
⚡ CPU Simulation compare[33] 505.5 µs 448.8 µs +12.63%
⚡ CPU Simulation compare[34] 506.6 µs 450.9 µs +12.35%
⚡ CPU Simulation compare[36] 515 µs 459.6 µs +12.05%
⚡ CPU Simulation compare[35] 520.6 µs 465 µs +11.95%
⚡ CPU Simulation compare[31] 484.4 µs 433.1 µs +11.85%
⚡ CPU Simulation compare[30] 468.6 µs 419.4 µs +11.73%
⚡ CPU Simulation compare[29] 464.6 µs 416.1 µs +11.66%
⚡ CPU Simulation compare[28] 439 µs 393.8 µs +11.48%
⚡ CPU Simulation compare[38] 538.1 µs 483 µs +11.42%
⚡ CPU Simulation compare[37] 534.9 µs 481.1 µs +11.19%
⚡ CPU Simulation compare[39] 552.6 µs 497.8 µs +11.01%
⚡ CPU Simulation compare[27] 442.9 µs 400 µs +10.73%
⚡ CPU Simulation compare[42] 569.6 µs 514.9 µs +10.62%
⚡ CPU Simulation compare[26] 428.1 µs 387.1 µs +10.61%
⚡ CPU Simulation compare[25] 424.1 µs 383.7 µs +10.54%
⚡ CPU Simulation compare[44] 577.6 µs 523.2 µs +10.39%
⚡ CPU Simulation compare[41] 567.3 µs 514.1 µs +10.33%
⚡ CPU Simulation compare[43] 584.8 µs 530.5 µs +10.25%
⚡ CPU Simulation compare[46] 602.8 µs 546.9 µs +10.23%

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-fastlanes-compare-negate (18aaeeb) with develop (32390c0)

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