Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Exchange before GroupId to improve Partial Aggregation #105

Conversation

findepi
Copy link
Member

@findepi findepi commented Jan 29, 2019

The idea was abandoned during
prestodb/presto#11267 review.
@cla-bot cla-bot bot added the cla-signed label Jan 29, 2019
@findepi
Copy link
Member Author

findepi commented Jan 29, 2019

@sopel39 @kokosing during rebase i had to change (actually improve) the logic slightly. This comes as a separate fixup commit.

@findepi findepi force-pushed the findepi/master/add-exchange-before-groupid-to-improve-partial-aggregation-16b5ea branch from 8a9c180 to ca60479 Compare January 29, 2019 18:01
.map(newAggregation -> {
PlanNode newProject = project.replaceChildren(ImmutableList.of(newAggregation));
PlanNode newExchange = exchange.replaceChildren(ImmutableList.of(newProject));
return Result.ofPlanNode(newExchange);
Copy link
Member

Choose a reason for hiding this comment

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

I would inline these, then structure of the code matches the structure of the plan.


double aggregationMemoryRequirements = estimateAggregationMemoryRequirements(groupingKeys, groupId, groupingSetHistogram, context);
if (isNaN(aggregationMemoryRequirements) || aggregationMemoryRequirements < maxPartialAggregationMemoryUsage.toBytes()) {
// Aggregation will be effective even without exchanges.
Copy link
Member

Choose a reason for hiding this comment

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

it is not true when isNaN(aggregationMemoryRequirements)

* GroupId (before multiplication) makes partial aggregation more effective, resulting in less data being
* exchanged afterwards.
*/
public class AddExchangesBelowPartialAggregationOverGroupIdRuleSet
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to have unit test for that

Copy link
Member Author

Choose a reason for hiding this comment

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

That would probably be actually useless -- prestodb/presto#11741 (comment)

@@ -267,6 +268,7 @@ private LocalQueryRunner(Session defaultSession, FeaturesConfig featuresConfig,
requireNonNull(defaultSession, "defaultSession is null");
checkArgument(!defaultSession.getTransactionId().isPresent() || !withInitialTransaction, "Already in transaction");

this.taskManagerConfig = new TaskManagerConfig().setTaskConcurrency(4);
Copy link
Member

Choose a reason for hiding this comment

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

do we need that really?

Copy link
Member Author

Choose a reason for hiding this comment

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

need what? this only extracts TaskManagerConfig to a variable. I will separate this into preparatory commit

@findepi findepi force-pushed the findepi/master/add-exchange-before-groupid-to-improve-partial-aggregation-16b5ea branch from ca60479 to d7def7d Compare January 30, 2019 10:44
The rule brings significant improvement in TPC-DS Q22 and Q67 while not
causing much regression in other TPC-H, TPC-DS queries. (The only
observably regressing queries were still much better than non-CBO
baseline.)
@findepi findepi force-pushed the findepi/master/add-exchange-before-groupid-to-improve-partial-aggregation-16b5ea branch from cd5fc64 to 270f8a3 Compare January 30, 2019 11:03
@findepi findepi merged commit dc1d66f into trinodb:master Feb 1, 2019
@findepi findepi deleted the findepi/master/add-exchange-before-groupid-to-improve-partial-aggregation-16b5ea branch February 1, 2019 08:24
@findepi findepi mentioned this pull request Feb 1, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants