refactor: remove arrow-ord dependency in arrow-cast#8716
refactor: remove arrow-ord dependency in arrow-cast#8716Weijun-H wants to merge 4 commits intoapache:mainfrom
arrow-ord dependency in arrow-cast#8716Conversation
arrow_ordarrow-ord dependency in arrow-cast
|
Could you try running the benchmark in this PR #8710 and see what the difference is? I thought |
a6198b8 to
c72af36
Compare
|
I just reviewed the benchmark in and I think it looks good to go. I'll merge it in and then run the benchmarks on this PR |
| values_indexes.push(0); | ||
| let mut current_data = array.slice(0, 1).to_data(); | ||
| for idx in 1..array.len() { | ||
| let next_data = array.slice(idx, 1).to_data(); |
There was a problem hiding this comment.
I think this is likely to be substantially slower than what partition does, but we can see what the benchmarks show
arrow-cast/src/cast/run_array.rs
Outdated
| @@ -134,16 +134,8 @@ pub(crate) fn cast_to_run_end_encoded<K: RunEndIndexType>( | |||
| )); | |||
| } | |||
|
|
|||
| // Partition the array to identify runs of consecutive equal values | |||
| let partitions = partition(&[Arc::clone(cast_array)])?; | |||
| let mut run_ends = Vec::new(); | |||
There was a problem hiding this comment.
Oh, great idea!
Side note: How did you profile this, using samply (it looks like), cargo build --profile profiling, and ran e.g. a unit test?
There was a problem hiding this comment.
I used Instruments that was part of Mac XCode -- it is pretty sweet as it will do whole system profiling (fire it up and start recording and it gathers the info for all processes)
There was a problem hiding this comment.
Pushed your suggestion as a PR here: #8716, maybe you can run the benchmark on that too? 😇
|
🤖 |
|
🤖: Benchmark completed Details
|
As @vegarsti predicted, this PR appears to be quite a bit slower than using partition |
70b24d1 to
fe208be
Compare
|
FYI @vegarsti , @alamb After several rounds of optimization, the current version delivers significant improvements over the previous one.
|
|
🤖 |
|
🤖: Benchmark completed Details
|
Related to #8707. Inspired by #8716 (comment), a follow up improvement to #8589: We already know what the length of the two vectors will be, so we can create them with that capacity.
f9fc4fe to
4fd7761
Compare
Jefffrey
left a comment
There was a problem hiding this comment.
Are we still interested in getting this through? Could we run bot benchmarks again (I don't think I have the permission)
| match array.data_type() { | ||
| Null => (vec![array.len()], vec![0]), | ||
| Boolean => runs_for_boolean(array.as_boolean()), | ||
| Int8 => runs_for_primitive(array.as_primitive::<Int8Type>()), |
There was a problem hiding this comment.
Could probably use downcast_primitive_array to cut down some of the boilerplate here?
| ) | ||
| } | ||
|
|
||
| fn runs_for_string_view(array: &StringViewArray) -> (Vec<usize>, Vec<usize>) { |
There was a problem hiding this comment.
Probably remove these thin wrappers since we have a catch-all for non-specialized types in the big match above?
| finalize_runs(run_boundaries, len) | ||
| } | ||
|
|
||
| fn runs_for_string_i32(array: &GenericStringArray<i32>) -> (Vec<usize>, Vec<usize>) { |
There was a problem hiding this comment.
fn runs_for_string<O: OffsetSizeTrait>(array: &GenericStringArray<O>) -> (Vec<usize>, Vec<usize>) {
let mut to_usize = |v: O| v.as_usize();
runs_for_binary_like(
array.len(),
array.null_count(),
array.value_offsets(),
array.value_data(),
|idx| array.is_valid(idx),
&mut to_usize,
)
}Nice deduplication
I added you here: alamb/datafusion-benchmarking@1f1e8b2 (though beware the benchmark machine is non ideal in that it is a shared VM and thus is prone to workload variations) |
|
run benchmark cast_kernels |
1 similar comment
|
run benchmark cast_kernels |
|
🤖 |
It seems to me like a good idea in theory -- I just didnt' have the time to follow it through and complete a review 😢 |
|
🤖: Benchmark completed Details
|
|
🤖 |
|
🤖: Benchmark completed Details
|

Which issue does this PR close?
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Existing tests cover this change
Are there any user-facing changes?
No