You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "neilconway (via GitHub)" <gi...@apache.org> on 2026/03/02 03:07:36 UTC
[PR] perf: Optimize `array_to_string` to avoid a copy [datafusion]
neilconway opened a new pull request, #20639:
URL: https://github.com/apache/datafusion/pull/20639
## Which issue does this PR close?
N/A
## Rationale for this change
`array_to_string` used a temporary buffer to convert array elements to a string, before then copying that buffer into a `StringBuilder` via `append_value`. We can skip this copy by arranging to write directly into the `StringBuilder's buffer because it implements `fmt::Write`. This is a 12-18% performance improvement on the `array_to_string` benchmarks.
## What changes are included in this PR?
* Optimization
* Change the signature of the `append` closure to return `Result`, which avoids a lot of `unwrap` clutter
## Are these changes tested?
Yes -- covered by existing tests and benchmarks.
## Are there any user-facing changes?
No.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: Optimize `array_to_string` to avoid a copy [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead merged PR #20639:
URL: https://github.com/apache/datafusion/pull/20639
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: Optimize `array_to_string` to avoid a copy [datafusion]
Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway commented on PR #20639:
URL: https://github.com/apache/datafusion/pull/20639#issuecomment-3981767906
cc @goldmedal , if you're interested in reviewing another small tweak to `array_to_string` 😊
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: Optimize `array_to_string` to avoid a copy [datafusion]
Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway commented on PR #20639:
URL: https://github.com/apache/datafusion/pull/20639#issuecomment-3981765281
Benchmarks:
```
┌──────────────────┬─────────────┐
│ Benchmark │ Improvement │
├──────────────────┼─────────────┤
│ int64/5 │ -16% │
├──────────────────┼─────────────┤
│ int64/20 │ -13% │
├──────────────────┼─────────────┤
│ int64/100 │ -12% │
├──────────────────┼─────────────┤
│ float64/5 │ -14% │
├──────────────────┼─────────────┤
│ float64/20 │ -13% │
├──────────────────┼─────────────┤
│ float64/100 │ -12% │
├──────────────────┼─────────────┤
│ string/5 │ -18% │
├──────────────────┼─────────────┤
│ string/20 │ -15% │
├──────────────────┼─────────────┤
│ string/100 │ -14% │
├──────────────────┼─────────────┤
│ nested_int64/5 │ -13% │
├──────────────────┼─────────────┤
│ nested_int64/20 │ -13% │
├──────────────────┼─────────────┤
│ nested_int64/100 │ -12% │
└──────────────────┴─────────────┘
```
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org