Skip to content

ARROW-11725: [Rust][DataFusion] Make use of the new divide_scalar kernel in arrow - #9543

Closed
abreis wants to merge 2 commits into
apache:masterfrom
abreis:datafusion-divide-scalar
Closed

ARROW-11725: [Rust][DataFusion] Make use of the new divide_scalar kernel in arrow#9543
abreis wants to merge 2 commits into
apache:masterfrom
abreis:datafusion-divide-scalar

Conversation

@abreis

Copy link
Copy Markdown
Contributor

This is a small PR to make DataFusion use the just-merged divide_scalar arrow kernel (#9454).

Performance-wise:

  • on the arrow side, this specialized kernel is ~40-50% faster than the standard divide, mostly due to not having to check for divide-by-zero on every row;
  • on the datafusion side, it can now skip the scalar.to_array_of_size(num_rows) allocation, which should be a decent win for operations on large arrays.

The eventual goal is to have op_scalar variants for every arithmetic operation — divide will show the biggest performance gains but all variants should save DataFusion a (possibly expensive) allocation.

@github-actions

Copy link
Copy Markdown

macro_rules! binary_string_array_op_scalar {
($LEFT:expr, $RIGHT:expr, $OP:ident) => {{
let result = match $LEFT.data_type() {
let result: Result<Arc<dyn Array>> = match $LEFT.data_type() {

@abreisabreisFeb 21, 2021

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I could not find a way to do this type erasure directly in BinaryExpr::evaluate (L419, which only had scalar operations on BooleanArray before), so I'm doing it here and also for binary_array_op_scalar (L244).

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @abreis -- looks really nice to me. @jorgecarleitao or @Dandandan any thoughts?

@DandandanDandandan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment threadrust/datafusion/src/physical_plan/expressions/binary.rs Outdated

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks againt @abreis

@alamb

Copy link
Copy Markdown
Contributor

I plan to merge this once the CI goes green

@abreis

Copy link
Copy Markdown
ContributorAuthor

CI failure seems unrelated. Note that the first commit already passed CI, and this second commit only changes a few error strings, so it should be safe to merge.

@alamb

Copy link
Copy Markdown
Contributor

The integration failure looks like https://issues.apache.org/jira/browse/ARROW-11717

@alambalamb closed this in 6a5ed0aFeb 23, 2021
@alamb

Copy link
Copy Markdown
Contributor

Merged. 🎉 Thanks @abreis

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@abreis@alamb@Dandandan