arrow icon indicating copy to clipboard operation
arrow copied to clipboard

[C++][Compute] Investigate prefix-aware early rejection for StringView equality kernels

Open Awesome06 opened this issue 1 month ago • 0 comments

Describe the enhancement requested

In #55171 (GH-54668), direct comparison kernels were added between StringView/BinaryView and standard offset-based string types.

As noted by @dmitry-chirkov-dremio in PR review, equality comparisons (equal, not_equal) can leverage the 4-byte inline prefix in the view descriptor to reject mismatches without dereferencing variadic payload buffers (yielding ~1.8x–2x speedups on workloads with ~50% early mismatches).

Currently, these kernels execute via applicator::ScalarBinary with ArrayIterator<BinaryViewType>, which eagerly calls util::FromBinaryView and dereferences payload buffers for all strings > 12 bytes upfront before comparison logic runs.

This issue tracks:

  1. Prefix-aware fast paths:
    • View vs. View: Compare combined 64-bit (length, prefix) before accessing variadic buffers (leveraging util::EqualBinaryView or vectorized loops).
    • View vs. String: Check length and match the view's 4-byte prefix against the offset string's buffer without dereferencing the view's payload buffer.
    • Bypassing eager ArrayIterator resolution (e.g. via dedicated vectorized loops writing bit-packed booleans).
  2. Benchmarking & heuristics:
    • Benchmark across mismatch distributions (0% mismatch, ~50% early mismatch, 100% prefix collision).
    • Explore adaptive heuristics (such as batch sampling) to ensure prefix checks don't add net overhead when strings match.

Component(s)

C++, Compute

Awesome06 avatar Oct 25 '26 19:10 Awesome06