[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.
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.
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.
LGTM, tho I question the utility of one bit of complexity this PR adds.
| 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.
The branch to test for zero probably costs more than applying an offset of zero?
There was a problem hiding this comment.
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.
Thanks @codephage2020 @scovich and @friendlymatthew
| 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.
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.