zhuqi-lucas commented on code in PR #7731:
URL: https://github.com/apache/arrow-rs/pull/7731#discussion_r2160529686
##########
arrow-ord/src/cmp.rs:
##########
@@ -565,24 +565,46 @@ impl<'a, T: ByteViewType> ArrayOrd for &'a
GenericByteViewArray<T> {
/// Item.0 is the array, Item.1 is the index
type Item = (&'a GenericByteViewArray<T>, usize);
+ #[inline(always)]
fn is_eq(l: Self::Item, r: Self::Item) -> bool {
- // # Safety
- // The index is within bounds as it is checked in value()
let l_view = unsafe { l.0.views().get_unchecked(l.1) };
- let l_len = *l_view as u32;
-
let r_view = unsafe { r.0.views().get_unchecked(r.1) };
+ let l_len = *l_view as u32;
let r_len = *r_view as u32;
// This is a fast path for equality check.
// We don't need to look at the actual bytes to determine if they are
equal.
if l_len != r_len {
return false;
}
+ // When both len are same, we can compare the inlined bytes, this can
handle the corner case after
Review Comment:
After this change, eq optimize a lot, 4.75 faster.
```rust
critcmp main fast_path_view --filter "inlined bytes"
group fast_path_view
main
----- --------------
----
eq StringViewArray StringViewArray inlined bytes 1.00 2.7±0.01ms
? ?/sec 4.75 12.8±0.10ms ? ?/sec
lt StringViewArray StringViewArray inlined bytes 1.00 47.3±0.55ms
? ?/sec 1.12 52.8±1.38ms ? ?/sec
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]