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 all commits
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
41 changes: 35 additions & 6 deletions arrow/benches/comparison_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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())
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");

// 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| {
Expand Down Expand Up @@ -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"))
});
Expand Down
Loading