Skip to content

Share FastLanes compare kernels between operators and signedness - #10739

Merged
connortsui20 merged 2 commits into
developfrom
rk/size-fastlanes-compare-negate
Oct 26, 2026
Merged

connortsui20 merged 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
@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

@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 2 benchmarks

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 2 benchmarks

These benchmarks measured no execution time, so their results are not comparable and count 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

⚡ 24 improved benchmarks
❌ 2 regressed benchmarks
✅ 2413 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 bench_compare_sliced_dict_primitive[(3333, 10000)] 32.9 µs 71 µs -53.63%
❌ CPU Simulation filter_powerlaw_by_random[250000] 131.3 µs 174.3 µs -24.66%
⚡ CPU Simulation chunked_dict_primitive_canonical_into[f64, (1000, 1000, 10)] 203.3 µs 149.4 µs +36.07%
⚡ CPU Simulation compare[33] 503.3 µs 446.1 µs +12.82%
⚡ CPU Simulation compare[34] 504.3 µs 447.8 µs +12.62%
⚡ CPU Simulation compare[36] 512.5 µs 456.3 µs +12.31%
⚡ CPU Simulation compare[35] 518.3 µs 461.9 µs +12.2%
⚡ CPU Simulation compare[31] 482 µs 429.9 µs +12.1%
⚡ CPU Simulation compare[30] 466 µs 416.2 µs +11.98%
⚡ CPU Simulation compare[29] 462.1 µs 413.1 µs +11.86%
⚡ CPU Simulation compare[28] 436.7 µs 390.7 µs +11.77%
⚡ CPU Simulation compare[38] 535.6 µs 479.6 µs +11.67%
⚡ CPU Simulation compare[37] 532.7 µs 478.2 µs +11.4%
⚡ CPU Simulation compare[39] 550.2 µs 494.6 µs +11.24%
⚡ CPU Simulation compare[27] 440.5 µs 396.9 µs +10.99%
⚡ CPU Simulation decompress[u16, (4000, 256)] 62.5 µs 56.3 µs +10.98%
⚡ CPU Simulation compare[26] 425.6 µs 383.8 µs +10.89%
⚡ CPU Simulation compare[42] 567.1 µs 511.7 µs +10.84%
⚡ CPU Simulation compare[25] 421.8 µs 380.7 µs +10.78%
⚡ CPU Simulation compare[44] 575.4 µs 520.3 µs +10.59%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

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 (47f9018) with develop (76d8371)

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

Comment on lines +106 to +107
let cmp = move |value: T, other: T| base.apply(value, other);
let exact = move |value: T| cmp(value, rhs) != negate;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wow compilers

@connortsui20
connortsui20 enabled auto-merge (squash) October 26, 2026 16:20
@connortsui20
connortsui20 force-pushed the rk/size-fastlanes-compare-negate branch from 18aaeeb to ef20ffc Compare October 26, 2026 16:20
robert3005 and others added 2 commits October 26, 2026 16:21
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 <github@robertk.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <github@robertk.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robert3005
robert3005 force-pushed the rk/size-fastlanes-compare-negate branch from ef20ffc to 47f9018 Compare October 26, 2026 16:21
@connortsui20
connortsui20 merged commit 6f42379 into develop Oct 26, 2026
79 of 81 checks passed
@connortsui20
connortsui20 deleted the rk/size-fastlanes-compare-negate branch October 26, 2026 16:31
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.

2 participants