You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "goldmedal (via GitHub)" <gi...@apache.org> on 2024/10/19 17:47:04 UTC
[PR] POC: Try to optimize `columnized_output_exprs` [datafusion]
goldmedal opened a new pull request, #13018:
URL: https://github.com/apache/datafusion/pull/13018
## 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.
-->
## 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: 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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#issuecomment-2564136561
Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#issuecomment-2441300974
Thanks for double checking @goldmedal
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#issuecomment-2435068514
I may be misreading this, but it seems like columnize_output_expr is called in a loop for each expression being projected:
https://github.com/apache/datafusion/blob/ac827abe1b66b1dfa02ce65ae857477f68667843/datafusion/expr/src/logical_plan/builder.rs#L1505-L1511
However, then for each expr it builds up the same hash table:
https://github.com/apache/datafusion/blob/ac827abe1b66b1dfa02ce65ae857477f68667843/datafusion/expr/src/utils.rs#L879-L883
Maybe we could refactor the code so the hash table is built once rather than once per expression? Something like
```rust
let columizer = Columnizer(plan);
for e in exprs {
columnizer.columnize(e)
}
```
🤔
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#issuecomment-2440038947
> However, then for each expr it builds up the same hash table:
>
> https://github.com/apache/datafusion/blob/ac827abe1b66b1dfa02ce65ae857477f68667843/datafusion/expr/src/utils.rs#L879-L883
It doesn't work for this case because the hash tables are different. The case is
```
SELECT max(a1), max(a2), ... max(a200) from t
```
I think sharing the hash map may work in some cases like
```
SELECT max(a1), max(a1) + 1, max(a1) +2, ... from t
```
We only need to hash `max(a1)` once, and then look up the column reference many times. In `physical_select_aggregates_from_200` case, we still need to hash every expression.
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan commented on code in PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#discussion_r1807640271
##########
datafusion/common/src/dfschema.rs:
##########
@@ -478,6 +479,14 @@ impl DFSchema {
.collect()
}
+ pub fn column_reference(&self) -> Vec<ColumnReference> {
+ self.iter()
+ .map(|(qualifier, field)| {
+ ColumnReference::new(qualifier.cloned(), field.name().as_str())
+ })
+ .collect()
Review Comment:
This `Vec` can be avoided by returning iterator?
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal closed pull request #13018: POC: Try to optimize `columnized_output_exprs`
URL: https://github.com/apache/datafusion/pull/13018
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on code in PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#discussion_r1807743369
##########
datafusion/common/src/dfschema.rs:
##########
@@ -478,6 +479,14 @@ impl DFSchema {
.collect()
}
+ pub fn column_reference(&self) -> Vec<ColumnReference> {
+ self.iter()
+ .map(|(qualifier, field)| {
+ ColumnReference::new(qualifier.cloned(), field.name().as_str())
+ })
+ .collect()
Review Comment:
Indeed, nice idea. Thanks!
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#issuecomment-2425043176
The latest commit doesn't make the performance better. Just clean up the codebase.
--
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] POC: Try to optimize `columnized_output_exprs` [datafusion]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on PR #13018:
URL: https://github.com/apache/datafusion/pull/13018#issuecomment-2437067461
> coupled with your changes to avoid hash map might make a significant difference in planning
Thanks, @alamb. I'll check it in a few days. If it makes sense, I will do the benchmark again 👍
--
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