Repository navigation
Conversation
|
|
|
|
|
@dmitry-chirkov-dremio Based on our prior conversation, here are the benchmark measurements evaluating the direct prefix path versus the adaptive sampling heuristic on GH-55254. Benchmark Notes: Direct Prefix (Option A) vs. Adaptive Sampling (Option B)We evaluated the adaptive heuristic prototyping 32 evenly spaced sampled pairs per batch (triggering the prefix path on >= 4 sample rejections for mixed types, >= 8 for view/view, and falling back to the baseline executor below 4,096 rows): Comparative Benchmark Results:
Takeaways:
|
|
|
…gView equality kernels ### Rationale for this change In apache#55171, direct comparison kernels were added between StringView/BinaryView and offset-based string types. Those kernels relied on `applicator::ScalarBinary` with `ArrayIterator<BinaryViewType>`, which eagerly calls `util::FromBinaryView` and resolves variadic payload pointers for every element regardless of match outcome. As discussed in apache#55254, equality comparisons (`equal`, `not_equal`) can check the view's 4-byte inline prefix and string length before accessing payload buffers, rejecting mismatches early. ### What changes are included in this PR? 1. `util::EqualBinaryViewString`: Added in `arrow/util/binary_view_util.h` to compare a `BinaryViewType::c_type` with contiguous string data. It checks length and 4-byte prefix before dereferencing view variadic buffers. 2. Dedicated equality kernels: Implemented `ViewCompareViewEqual` and `ViewCompareStringEqual` in `scalar_compare.cc`, replacing eager iterator resolution for `equal` and `not_equal`. 3. Register-pinned scalar comparisons: For array-scalar operations, unpacked scalar length and prefix are pinned in registers outside the loop, avoiding repeated scalar lookups. 4. Tests: Extended `TestBinaryViewCompareKernel.ArrayArray` and `TestBinaryViewCompareKernel.ArrayScalar` with cases covering prefix mismatch, out-of-line equality, null bytes, and long strings. ### Are these changes tested? Yes, extended existing parameterized tests in `scalar_compare_test.cc`. ### Are there any user-facing changes? No. ### Was AI used for this PR? AI was used to assist with kernel registration and testing under human direction. **PR code and description written by:** - [ ] Human - [x] AI **Reviewed before submission by:** - [x] Human - [x] AI - [ ] Not reviewed * GitHub Issue: apache#55254
3660d80 to
de62926
Compare
…uality kernels - Extract shared ViewArrayCompareBinaryScalarEqual helper to decouple View and String kernel structs. - Optimize variadic payload comparisons by skipping the verified 4-byte prefix. - Use stateless indexed offset traversal in ViewCompareStringEqual::ArrayArray. - Clean up boolean expressions and add Doxygen API documentation in binary_view_util.h. - Add asymmetric slice test coverage in scalar_compare_test.cc.
|
Should be add "OG baseline" to the comparison (i.e. cast + comparison) so we are discouraged by few perf "losses"? p.s. what sort of feedback are you looking for with this PR? |
|
@dmitry-chirkov-dremio I updated the earlier benchmark table with the OG baseline (cast + comparison). Also letting you know that #54668 has been merged and is the active baseline. Regarding feedback for this PR:
|
|
@Awesome06 what is your personal recommendation? |
…lti-buffer tests - Early return on BaseBinaryScalar length exceeding INT32_MAX to prevent 32-bit truncation in ViewArrayCompareBinaryScalarEqual. - Add test coverage for inlined prefix collisions (abcdefgh vs abcdefgX) in ArrayArray and ArrayScalar compare kernels. - Add MultiplePayloadBuffers test case verifying cross-buffer comparisons and buffer index dereferencing.
|
@dmitry-chirkov-dremio Yes, I think it is well worth it. Baseline was simple only because it used the generic executor and ignored the 4-byte prefix. In real workloads (selective filters), 90%+ of rows are mismatches or short inline strings, where Option A is 4.7x faster on scalars, 2x on mismatches, and 1.5x on inline strings. The ~14% drop only hits when 100% of rows are identical >12 B strings, and even there it remains 3x faster than the OG baseline. Trading that corner-case for 4.7x on selective filters fulfills why we use StringView, without needing runtime heuristics like Option B. |
|
Sorry, I'm slow today. I got lost in options A and B. If yes, could you clarify the wins/losses of A vs B again? In your earlier comment you seem to have implied you prefer A yourself, no? Or is that the impression you got from me? |
What Each Option Means
Why Option A is the Right Path Forward
|
dmitry-chirkov-dremio
left a comment
There was a problem hiding this comment.
Thanks, clear now. I lean toward A. Please summarize the gains and the slowdown against the merged baseline in the PR description.
|
Updated the PR description with the benchmark comparison and trade-off summary against the #55171 baseline. |
|
|
1 similar comment
|
|
|
|
Rationale for this change
In #55171, direct comparison kernels were added between StringView/BinaryView and offset-based string types. Those kernels relied on
applicator::ScalarBinarywithArrayIterator<BinaryViewType>, which eagerly callsutil::FromBinaryViewand resolves variadic payload pointers for every element regardless of match outcome.As discussed in #55254, equality comparisons (
equal,not_equal) can check the view's 4-byte inline prefix and string length before accessing payload buffers, rejecting mismatches early.What changes are included in this PR?
util::EqualBinaryViewString: Added inarrow/util/binary_view_util.hto compare aBinaryViewType::c_typewith contiguous string data, checking length and 4-byte prefix before dereferencing view variadic buffers.ViewCompareViewEqualandViewCompareStringEqualinscalar_compare.cc, replacing eager iterator resolution forequalandnot_equal.TestBinaryViewCompareKernel.ArrayArrayandTestBinaryViewCompareKernel.ArrayScalarwith cases covering prefix mismatch, out-of-line equality, null bytes, and long strings.Performance results (vs merged #55171 baseline)
memcmp.memcmp.Are these changes tested?
Yes, extended existing parameterized tests in
scalar_compare_test.cc.Are there any user-facing changes?
No.
Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by:
Closes #55254