Skip to content

Conversation

simonvandel
Copy link
Contributor

Which issue does this PR close?

N/A

Rationale for this change

I haven't looked at the generated code, but i presume that using try_unary can lead to better vectorization.

What changes are included in this PR?

  • Add benchmark for date_trunc
  • Prefer using try_unary over iter-map combo.
date_trunc_minute_1000  time:   [12.745 µs 12.794 µs 12.849 µs]
                        change: [-19.871% -19.544% -19.210%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

Are these changes tested?

Using existing tests.

Are there any user-facing changes?

Faster date_trunc

Simon Vandel Sillesen added 2 commits February 10, 2025 22:23
date_trunc_minute_1000  time:   [12.745 µs 12.794 µs 12.849 µs]
                        change: [-19.871% -19.544% -19.210%] (p = 0.00 <
0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

remove todo
@github-actions github-actions bot added the functions Changes to functions implementation label Feb 10, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @simonvandel -- this looks good to me 🚀 🦾

.collect::<Result<PrimitiveArray<T>>>()?
let array: PrimitiveArray<T> = array
.try_unary(|x| {
general_date_trunc(T::UNIT, x, parsed_tz, granularity.as_str())
Copy link
Contributor

Choose a reason for hiding this comment

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

looking at the code, I think even more could be gained by having general_date_trunc operate on the array rather than per value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can take a look at that. Would it be okay to do so in another PR?
Then we have the benchmark on main

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, please do do so in a follow on PR -- let's leave this one as is

Thanks @simonvandel

@alamb alamb merged commit abb7669 into apache:main Feb 12, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Changes to functions implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants