Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in comparison_kernel benchmarks #6284

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions arrow/benches/comparison_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ 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_view_scalar = StringViewArray::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| {
Expand All @@ -193,7 +194,7 @@ fn add_benchmark(c: &mut Criterion) {
});

c.bench_function("eq scalar StringViewArray", |b| {
b.iter(|| eq(&scalar, &string_view_left).unwrap())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the panic came from this line which passes a scalar of type StringArray to a comparison kernel with StringViewArray -- the fix was to make the appropriate scalar type with let string_view_scalar = StringViewArray::new_scalar("xxxx");

b.iter(|| eq(&string_view_scalar, &string_view_left).unwrap())
});

c.bench_function("eq StringArray StringArray", |b| {
Expand Down Expand Up @@ -240,10 +241,18 @@ fn add_benchmark(c: &mut Criterion) {
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 starts with less than 4 bytes", |b| {
b.iter(|| bench_like_utf8view_scalar(&string_view_left, "xxxx%"))
});

c.bench_function("like_utf8view scalar starts with more than 4 bytes", |b| {
b.iter(|| bench_like_utf8view_scalar(&string_view_left, "xxxxxx%"))
});

c.bench_function("like_utf8view scalar starts with more than 12 bytes", |b| {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added a second function for more than 12 bytes

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"))
});
Expand Down
Loading