JasonLi-cn opened a new pull request, #10006:
URL: https://github.com/apache/arrow-datafusion/pull/10006
## 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. For example `Closes #123`
indicates that this PR will close issue #123.
-->
Closes #.
## Rationale for this change
If the `trim` function includes a second argument, I believe it is
predominantly a Scalar rather than an Array. Expanding the second argument into
an Array would lead to performance degradation, and more critically, the code
`arg.clone().into_array(expansion_len)` would be invoked for every computation.
### Benchmark
```shell
Gnuplot not found, using plotters backend
ltrim ": 1024 time: [23.495 µs 23.520 µs 23.554 µs]
change: [-11.992% -11.922% -11.854%] (p = 0.00 <
0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high severe
ltrim ": 4096 time: [92.348 µs 92.489 µs 92.669 µs]
change: [-10.305% -10.123% -9.9762%] (p = 0.00 <
0.05)
Performance has improved.
Found 15 outliers among 100 measurements (15.00%)
6 (6.00%) high mild
9 (9.00%) high severe
ltrim ": 8192 time: [189.78 µs 190.59 µs 191.57 µs]
change: [-6.1871% -5.8626% -5.5516%] (p = 0.00 <
0.05)
Performance has improved.
ltrim Header:: 1024 time: [80.256 µs 80.276 µs 80.300 µs]
change: [-7.5562% -7.0325% -6.6364%] (p = 0.00 <
0.05)
Performance has improved.
ltrim Header:: 4096 time: [318.94 µs 319.04 µs 319.15 µs]
change: [-5.5723% -5.4562% -5.3322%] (p = 0.00 <
0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe
ltrim Header:: 8192 time: [643.04 µs 643.69 µs 644.34 µs]
change: [-4.9289% -4.7291% -4.5327%] (p = 0.00 <
0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) high mild
2 (2.00%) high severe
```
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
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 add the `api
change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]