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

planner: consider agg func type in cost model #12038

Merged
merged 3 commits into from
Sep 9, 2019

Conversation

lzmhhh123
Copy link
Contributor

What problem does this PR solve?

After PR #11926. We found that aggregation didn't push to cop task for TPCH Q1. The reason is explained by issue #11948. This PR changes the cost model to consider agg function types simply.

What is changed and how it works?

Add factor for each agg function instead of the number of agg functions.

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Possible performance regression
  • Increased code complexity

@lzmhhh123 lzmhhh123 added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner labels Sep 5, 2019
@codecov
Copy link

codecov bot commented Sep 5, 2019

Codecov Report

Merging #12038 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #12038   +/-   ##
===========================================
  Coverage   81.5318%   81.5318%           
===========================================
  Files           448        448           
  Lines         96198      96198           
===========================================
  Hits          78432      78432           
  Misses        12192      12192           
  Partials       5574       5574

if numAggFunc == 0 {
numAggFunc = 1
aggFactorSum := 0.0
for _, agg := range p.AggFuncs {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not extract a function for them?

}
}
if aggFactorSum == 0 {
aggFactorSum = 1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

So no agg func has more cost that single bitXXX? That seems weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My opinion is that bit operation costs lower than other base operations.

@@ -43,6 +44,24 @@ const (
distinctFactor = 0.8
)

var aggFuncFactor = map[string]float64{
ast.AggFuncCount: 1.0,
Copy link
Member

Choose a reason for hiding this comment

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

How do you dicide their values?
And what is defalut for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. The values are how they keep the result of their arguments. For example:
avg: avg.sum += expr, avg.cnt += 1
var_pop: var_pop.sum_sqr += expr*expr, var_pop.cnt += 1, var_pop.sum += expr
  1. The default is just for safety.

Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

@lzmhhh123 lzmhhh123 added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 9, 2019
Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

lgtm

@lzmhhh123 lzmhhh123 added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 9, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 9, 2019

Your auto merge job has been accepted, waiting for #12092

@sre-bot
Copy link
Contributor

sre-bot commented Sep 9, 2019

/run-all-tests

@sre-bot sre-bot merged commit bb5bfa4 into pingcap:master Sep 9, 2019
@lzmhhh123 lzmhhh123 deleted the fix_cost_model branch September 25, 2019 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants