Skip to content

Conversation

alamb
Copy link

@alamb alamb commented Oct 17, 2024

Targets apache#12950

This is a proposal to add even more Arc to the AggregateFunctionExpr in order to reduce more deep clones

askalt and others added 4 commits October 15, 2024 23:08
This patch adds a benchmark aimed at tracking inefficiencies at the stage of creating/optimizing a physical plan.
Patch f5c47fa removed Arc wrappers for AggregateFunctionExpr.
But, it can be inefficient. When physical optimizer decides to replace a node child to other,
it clones the node (with `with_new_children`). Assume, that node is `AggregateExec` than contains
hundreds aggregates and these aggregates are cloned each time.

This patch returns a Arc wrapping to not clone AggregateFunctionExpr itself but clone a pointer.
This patch adds a small optimization that can soft the edges on
some queries. If there are no parent requirements we do not need to
build column mapping.

AggregateExprBuilder::new(Arc::new(updated_fn), self.args.to_vec())
.order_by(self.ordering_req.to_vec())
.schema(Arc::new(self.schema.clone()))
Copy link
Author

Choose a reason for hiding this comment

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

In particular, I believe this is a deep clone

) -> Result<Option<AggregateFunctionExpr>> {
let Some(updated_fn) = self
.fun
.clone()
Copy link
Author

Choose a reason for hiding this comment

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

this was also a deep clone

@alamb
Copy link
Author

alamb commented Oct 18, 2024

Will create a PR to DataFusion main instead

@alamb alamb closed this Oct 18, 2024
@askalt
Copy link
Owner

askalt commented Oct 19, 2024

Will create a PR to DataFusion main instead

Ok, thank you, I was busy yesterday, I didn't have time to merge it :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants