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

*: replace cost model factor constants with system variable #12367

Merged
merged 2 commits into from
Sep 30, 2019

Conversation

eurekaka
Copy link
Contributor

What problem does this PR solve?

As the title said, replace hard-coded cost model factor constants with system variables, to make it more flexible for re-configuration to fit into customized environments.

What is changed and how it works?

Add 7 system variables corresponding to the constant factors, and use them in cost computing.

Check List

Tests

  • Unit test

Code changes

  • Has exported variable/fields change

Side effects

N/A

Related changes

  • Need to update the documentation

Release note

N/A

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

codecov bot commented Sep 25, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@f146185). Click here to learn what that means.
The diff coverage is 89.928%.

@@             Coverage Diff             @@
##             master     #12367   +/-   ##
===========================================
  Coverage          ?   80.7625%           
===========================================
  Files             ?        454           
  Lines             ?      99431           
  Branches          ?          0           
===========================================
  Hits              ?      80303           
  Misses            ?      13336           
  Partials          ?       5792

// tidb_opt_memory_factor is the memory cost of storing one tuple.
TiDBOptMemoryFactor = "tidb_opt_memory_factor"
// tidb_opt_concurrency_factor is the CPU cost of additional one goroutine.
TiDBOptConcurrencyFactor = "tidb_opt_concurrency_factor"
Copy link
Member

Choose a reason for hiding this comment

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

How about renaming them in the format of tidb_opt_factor_xxx? So that we can search all the factors with a simple sql like show variables like "tidb_opt_factor%.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would look strange for variables like tidb_opt_factor_cpu, we can use show variables like "tidb_opt_%_factor" to query all the values instead?

}
if v < 0 {
return value, ErrWrongValueForVar.GenWithStackByArgs(name, value)
}
Copy link
Member

Choose a reason for hiding this comment

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

should we validate the upper limit for each variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How should we set the upper limit for the variables?

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

@eurekaka eurekaka added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 26, 2019
Copy link
Contributor

@lzmhhh123 lzmhhh123 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 30, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 30, 2019

/run-all-tests

@sre-bot sre-bot merged commit 1a9fcb9 into pingcap:master Sep 30, 2019
lzmhhh123 pushed a commit to lzmhhh123/tidb that referenced this pull request Jan 19, 2020
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.

5 participants