lyne7-sc opened a new pull request, #22119:
URL: https://github.com/apache/datafusion/pull/22119
## 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
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
array_replace / array_replace_n / array_replace_all currently call
`MutableArrayData::extend` once per non-matching element. This pr batches
consecutive non-matching elements into a single extend call, reducing call
count.
## 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.
-->
- Track contiguous non-matching runs and flush them as one extend call.
- Add Criterion benchmark and SLT edge-case tests for n = 0 / -1 / >
match_count.
### Benchmarks
```
group
main perf
-----
---- ----
array_replace_all_int64/replace/list size: 10, num_rows: 4000
1.06 1149.7±23.40µs ? ?/sec 1.00 1080.3±71.22µs ? ?/sec
array_replace_all_int64/replace/list size: 100, num_rows: 10000
1.70 11.2±0.19ms ? ?/sec 1.00 6.6±0.36ms ? ?/sec
array_replace_all_int64/replace/list size: 500, num_rows: 10000
1.94 44.2±0.71ms ? ?/sec 1.00 22.8±0.48ms ? ?/sec
array_replace_all_int64_nested/replace/list size: 10, num_rows: 4000
1.03 7.4±0.05ms ? ?/sec 1.00 7.2±0.26ms ? ?/sec
array_replace_all_int64_nested/replace/list size: 100, num_rows: 3000
1.14 42.1±0.57ms ? ?/sec 1.00 36.9±0.22ms ? ?/sec
array_replace_all_int64_nested/replace/list size: 300, num_rows: 1500
1.14 60.5±2.57ms ? ?/sec 1.00 52.8±0.60ms ? ?/sec
array_replace_boolean/replace/list size: 10, num_rows: 4000
1.04 1087.5±25.31µs ? ?/sec 1.00 1042.4±18.85µs ? ?/sec
array_replace_boolean/replace/list size: 100, num_rows: 10000
1.20 4.2±0.13ms ? ?/sec 1.00 3.5±0.06ms ? ?/sec
array_replace_boolean/replace/list size: 500, num_rows: 10000
1.11 7.0±0.28ms ? ?/sec 1.00 6.3±0.06ms ? ?/sec
array_replace_fixed_size_binary/replace/list size: 10, num_rows: 4000
1.03 1187.3±13.63µs ? ?/sec 1.00 1155.9±26.39µs ? ?/sec
array_replace_fixed_size_binary/replace/list size: 100, num_rows: 10000
1.01 7.0±0.08ms ? ?/sec 1.00 6.9±0.67ms ? ?/sec
array_replace_fixed_size_binary/replace/list size: 500, num_rows: 10000
1.00 23.6±0.61ms ? ?/sec 1.01 23.8±0.92ms ? ?/sec
array_replace_int64/replace/list size: 10, num_rows: 4000
1.07 1071.8±25.30µs ? ?/sec 1.00 1003.3±24.68µs ? ?/sec
array_replace_int64/replace/list size: 100, num_rows: 10000
1.16 4.0±0.07ms ? ?/sec 1.00 3.4±0.09ms ? ?/sec
array_replace_int64/replace/list size: 500, num_rows: 10000
1.10 7.2±0.31ms ? ?/sec 1.00 6.6±0.34ms ? ?/sec
array_replace_int64_nested/replace/list size: 10, num_rows: 4000
1.02 7.2±0.07ms ? ?/sec 1.00 7.0±0.21ms ? ?/sec
array_replace_int64_nested/replace/list size: 100, num_rows: 3000
1.01 36.1±0.38ms ? ?/sec 1.00 35.8±1.62ms ? ?/sec
array_replace_int64_nested/replace/list size: 300, num_rows: 1500
1.00 51.2±0.48ms ? ?/sec 1.00 51.1±0.67ms ? ?/sec
array_replace_n_int64/replace/list size: 10, num_rows: 4000
1.09 1119.2±24.61µs ? ?/sec 1.00 1022.4±20.53µs ? ?/sec
array_replace_n_int64/replace/list size: 100, num_rows: 10000
1.45 7.2±0.22ms ? ?/sec 1.00 5.0±0.16ms ? ?/sec
array_replace_n_int64/replace/list size: 500, num_rows: 10000
1.68 25.3±0.38ms ? ?/sec 1.00 15.1±1.32ms ? ?/sec
array_replace_n_int64_nested/replace/list size: 10, num_rows: 4000
1.03 7.4±0.08ms ? ?/sec 1.00 7.1±0.07ms ? ?/sec
array_replace_n_int64_nested/replace/list size: 100, num_rows: 3000
1.05 38.5±0.36ms ? ?/sec 1.00 36.5±1.38ms ? ?/sec
array_replace_n_int64_nested/replace/list size: 300, num_rows: 1500
1.04 55.0±0.41ms ? ?/sec 1.00 52.6±1.99ms ? ?/sec
array_replace_strings/replace/list size: 10, num_rows: 4000
1.07 1443.5±18.35µs ? ?/sec 1.00 1348.6±41.07µs ? ?/sec
array_replace_strings/replace/list size: 100, num_rows: 10000
1.09 10.9±0.17ms ? ?/sec 1.00 9.9±0.17ms ? ?/sec
array_replace_strings/replace/list size: 500, num_rows: 10000
1.00 36.2±0.82ms ? ?/sec 1.04 37.5±0.91ms ? ?/sec
```
## Are these changes tested?
Yes — existing SLT tests and new edge-case coverage.
<!--
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?
No.
<!--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]