This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 56f6942e3 Fix panic in comparison_kernel benchmarks (#6284)
56f6942e3 is described below

commit 56f6942e30d47b79929f421c26788be1c23d7350
Author: Andrew Lamb <[email protected]>
AuthorDate: Wed Aug 21 16:17:07 2024 -0400

    Fix panic in comparison_kernel benchmarks (#6284)
    
    * Fix panic in comparison_kernel benchmarks
    
    * Add other special case equality kernels
    
    * Add other benchmarks
---
 arrow/benches/comparison_kernels.rs | 41 +++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/arrow/benches/comparison_kernels.rs 
b/arrow/benches/comparison_kernels.rs
index 5d18a62d1..c8aa7dfcf 100644
--- a/arrow/benches/comparison_kernels.rs
+++ b/arrow/benches/comparison_kernels.rs
@@ -167,9 +167,9 @@ fn add_benchmark(c: &mut Criterion) {
     let string_right = StringArray::from_iter(array_gen);
     let string_view_right = StringViewArray::from_iter(string_right.iter());
 
-    let scalar = StringArray::new_scalar("xxxx");
+    let string_scalar = StringArray::new_scalar("xxxx");
     c.bench_function("eq scalar StringArray", |b| {
-        b.iter(|| eq(&scalar, &string_left).unwrap())
+        b.iter(|| eq(&string_scalar, &string_left).unwrap())
     });
 
     c.bench_function("lt scalar StringViewArray", |b| {
@@ -192,8 +192,20 @@ fn add_benchmark(c: &mut Criterion) {
         })
     });
 
-    c.bench_function("eq scalar StringViewArray", |b| {
-        b.iter(|| eq(&scalar, &string_view_left).unwrap())
+    // StringViewArray has special handling for strings with length <= 12 and 
length <= 4
+    let string_view_scalar = StringViewArray::new_scalar("xxxx");
+    c.bench_function("eq scalar StringViewArray 4 bytes", |b| {
+        b.iter(|| eq(&string_view_scalar, &string_view_left).unwrap())
+    });
+
+    let string_view_scalar = StringViewArray::new_scalar("xxxxxx");
+    c.bench_function("eq scalar StringViewArray 6 bytes", |b| {
+        b.iter(|| eq(&string_view_scalar, &string_view_left).unwrap())
+    });
+
+    let string_view_scalar = StringViewArray::new_scalar("xxxxxxxxxxxxx");
+    c.bench_function("eq scalar StringViewArray 13 bytes", |b| {
+        b.iter(|| eq(&string_view_scalar, &string_view_left).unwrap())
     });
 
     c.bench_function("eq StringArray StringArray", |b| {
@@ -236,14 +248,31 @@ fn add_benchmark(c: &mut Criterion) {
         b.iter(|| bench_like_utf8view_scalar(&string_view_left, "%xxxx%"))
     });
 
-    c.bench_function("like_utf8view scalar ends with", |b| {
+    // StringView has special handling for strings with length <= 12 and 
length <= 4
+    c.bench_function("like_utf8view scalar ends with 4 bytes", |b| {
         b.iter(|| bench_like_utf8view_scalar(&string_view_left, "%xxxx"))
     });
 
-    c.bench_function("like_utf8view scalar starts with", |b| {
+    c.bench_function("like_utf8view scalar ends with 6 bytes", |b| {
+        b.iter(|| bench_like_utf8view_scalar(&string_view_left, "%xxxxxx"))
+    });
+
+    c.bench_function("like_utf8view scalar ends with 13 bytes", |b| {
+        b.iter(|| bench_like_utf8view_scalar(&string_view_left, 
"%xxxxxxxxxxxxx"))
+    });
+
+    c.bench_function("like_utf8view scalar starts with 4 bytes", |b| {
         b.iter(|| bench_like_utf8view_scalar(&string_view_left, "xxxx%"))
     });
 
+    c.bench_function("like_utf8view scalar starts with 6 bytes", |b| {
+        b.iter(|| bench_like_utf8view_scalar(&string_view_left, "xxxxxx%"))
+    });
+
+    c.bench_function("like_utf8view scalar starts with 13 bytes", |b| {
+        b.iter(|| bench_like_utf8view_scalar(&string_view_left, 
"xxxxxxxxxxxxx%"))
+    });
+
     c.bench_function("like_utf8view scalar complex", |b| {
         b.iter(|| bench_like_utf8view_scalar(&string_view_left, "%xx_xx%xxx"))
     });

Reply via email to