Skip to content

perf: pack primitive comparison results in fixed-size chunks - #9948

Draft
mhk197 wants to merge 1 commit into
developfrom
mk/primitive-compare-bitmap
Draft

mhk197 wants to merge 1 commit into
developfrom
mk/primitive-compare-bitmap

Conversation

@mhk197

@mhk197 mhk197 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Primitive comparisons currently pack predicate results with a shift-and-OR reduction over 64 rows. In the ARM assembly inspected for this implementation, this expands narrow comparison masks into wider integer lanes and makes bitmap construction expensive.

Use the existing collect_bool_word packer for fixed 64-element chunks in primitive array/array and array/constant comparisons. Full chunks let the compiler prove safe indexing is in bounds and vectorize the predicates before byte-to-bit packing. Partial words use the existing scalar tail path.

Changes

  • Add private bitmap collectors in the primitive comparison module
  • Add 396 parameterized cases covering all 11 primitive types, all six comparison operators, empty inputs and bitmap boundaries, nulls, and constants on either side.

This is independent of NarrowArray and changes no benchmark source or public API.

Performance

Existing comparison benchmarks, unchanged, on Apple M5 Max (aarch64), Rust 1.98.0, 8,192 rows.

Median of three run medians per benchmark, 200 samples per run.

Existing benchmark Before After Speedup
compare_f32 4.249 µs 3.083 µs 1.38×
compare_float 5.499 µs 5.165 µs 1.06×
compare_int 3.083 µs 2.832 µs 1.09×
compare_int_constant 2.416 µs 2.082 µs 1.16×
compare_int_eq 3.124 µs 2.791 µs 1.12×
compare_int_nullable 3.374 µs 3.082 µs 1.09×
compare_u8 2.707 µs 1.040 µs 2.60×
compare_u64 3.124 µs 2.791 µs 1.12×

Reuse collect_bool_word for primitive comparison bitmaps while preserving
execution-context allocation and comparison semantics. Cover bitmap
boundaries, all primitive types, nulls, and constant operand orientation.

Signed-off-by: "Matt Katz" <mhkatz97@gmail.com>
@codspeed

codspeed Bot commented Sep 18, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 6.7%

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

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 13 improved benchmarks
❌ 15 regressed benchmarks
✅ 2225 untouched benchmarks
⏩ 218 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime compare_int_constant_avx2 3 µs 6.4 µs -52.63%
WallTime compare_int_avx2 3.5 µs 6.3 µs -44.54%
WallTime compare_int_nullable_avx2 3.9 µs 6.7 µs -41.53%
WallTime arrow_checked_add_u32_neon[16384] 12.3 µs 20.3 µs -39.52%
WallTime compare_u64_avx2 4 µs 6.3 µs -37.03%
WallTime compare_float_avx2 5.1 µs 8 µs -36.02%
WallTime compare_int_eq_avx2 3.5 µs 5.4 µs -35.47%
Simulation decode_primitives[f32, (1000, 512)] 42 µs 64.3 µs -34.68%
WallTime lt_i64_nullable_avx2 2.9 µs 4.2 µs -31.34%
WallTime mul_u64_nonnull_neon 15.4 µs 20.8 µs -26.12%
WallTime mul_i64_nonnull_neon 17.3 µs 20.4 µs -15.05%
WallTime multiply_shapes_neon[(16384, PerRowPerRow)] 17.3 µs 20.3 µs -14.65%
WallTime dbp_assemble_kernel_avx2[(I256, 8192)] 8.5 µs 9.8 µs -13.33%
WallTime filtered_owned_i64_avx2[OneNullInEight] 22.3 µs 25.7 µs -13.24%
WallTime mul_i32_nonnull_avx512 7.1 µs 7.9 µs -10.25%
WallTime compare_u8_avx2 3.4 µs 1.8 µs +92.08%
WallTime compare_u8_neon 3.9 µs 2.1 µs +86.39%
WallTime compare_f32_avx2 4.6 µs 3.2 µs +43.82%
WallTime compare_u8_avx512 2.4 µs 1.7 µs +38.72%
WallTime compare_f32_avx512 3.7 µs 2.7 µs +37.49%
... ... ... ... ... ...

ℹ️ 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 mk/primitive-compare-bitmap (0528bdb) with develop (c6678f3)

Open in CodSpeed

Footnotes

  1. 218 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant