-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Variant] Use simdutf8 for UTF-8 validation #7908
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
[Variant] Use simdutf8 for UTF-8 validation #7908
Conversation
Signed-off-by: codephage2020 <tingwangyan2020@163.com>
Signed-off-by: codephage2020 <tingwangyan2020@163.com>
|
CC @alamb @friendlymatthew @Dandandan . |
friendlymatthew
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @codephage2020. I just have a few comments
Signed-off-by: codephage2020 <tingwangyan2020@163.com>
Signed-off-by: codephage2020 <tingwangyan2020@163.com>
hi, @friendlymatthew . Thanks for your review! I've addressed all your comments in the latest update. |
friendlymatthew
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @codephage2020. I had some comments but overall LGTM
Signed-off-by: codephage2020 <tingwangyan2020@163.com>
scovich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tho I question the utility of one bit of complexity this PR adds.
parquet-variant/src/utils.rs
Outdated
| let offset_buffer = match offset { | ||
| 0 => slice_from_slice(slice, range)?, | ||
| _ => slice_from_slice_at_offset(slice, offset, range)?, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The branch to test for zero probably costs more than applying an offset of zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could get a benchmark and show
I agree that unless we have a benchmark that shows this optimization makes a measurable difference, it would be better to go with the simpler code
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @codephage2020 @scovich and @friendlymatthew
parquet-variant/src/utils.rs
Outdated
| let offset_buffer = match offset { | ||
| 0 => slice_from_slice(slice, range)?, | ||
| _ => slice_from_slice_at_offset(slice, offset, range)?, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could get a benchmark and show
I agree that unless we have a benchmark that shows this optimization makes a measurable difference, it would be better to go with the simpler code
|
CC @alamb @scovich . result: @scovich The results show that you are right. And I will delete the branch for testing zero. Below is the code for the benchmark test. Please let me know if there are any issues. This is a temporary test and I won't submit it. const LARGE_DATA_SIZE: usize = 1 << 20;
fn setup_data() -> Vec<u8> {
let mut rng = StdRng::seed_from_u64(42);
(0..LARGE_DATA_SIZE).map(|_| rng.random()).collect()
}
fn bench_simple_direct(c: &mut Criterion) {
let data = setup_data();
let range = 0..1000;
c.bench_function("direct_slice_at_offset_zero", |b| {
b.iter(|| {
let _ = black_box(slice_from_slice_at_offset(&data, 0, range.clone()));
})
});
}
fn bench_with_branch_zero_offset(c: &mut Criterion) {
let data = setup_data();
let range = 0..1000;
let offset = 0;
c.bench_function("branched_slice_at_offset_zero", |b| {
b.iter(|| {
let _ = black_box(match offset {
0 => slice_from_slice(&data, range.clone()),
_ => slice_from_slice_at_offset(&data, offset, range.clone()),
});
})
});
} |
Signed-off-by: codephage2020 <tingwangyan2020@163.com>
|
Hi @alamb , |
|
Sorry for the delay -- thank you @codephage2020 , @scovich and @friendlymatthew |
All good! Thank you @alamb, @scovich and @friendlymatthew for reviewing and merging this! |
Which issue does this PR close?
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
simdutf8as an optional dependency when validating metadata #7902.Rationale for this change
What changes are included in this PR?
simdutf8dependency for parquet-variantextract_and_validate_utf8_sliceAre these changes tested?
We typically require tests for all PRs in order to:
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
Are there any user-facing changes?
If there are user-facing changes then we may require documentation to be updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.