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

*: new store region score function for balance #1014

Merged
merged 23 commits into from Apr 19, 2018

Conversation

Connor1996
Copy link
Member

@Connor1996 Connor1996 commented Apr 9, 2018

When storage is in low space, pd just do nothing to balance. This pr introduces a new region score function for balance considering low space as well.

@Connor1996 Connor1996 changed the title *: new score formula [WIP] *: new score formula Apr 9, 2018
@Connor1996 Connor1996 requested review from disksing and nolouch and removed request for disksing April 9, 2018 04:05
return maxScore - available
}

k := (maxScore - (lowSpaceRatio+highSpaceRatio)*capacity) / ((1 - lowSpaceRatio - highSpaceRatio) * capacity)
Copy link
Contributor

Choose a reason for hiding this comment

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

add some description about the formula

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work well when the capacity is 1T?

server/config.go Outdated
@@ -352,6 +352,10 @@ type ScheduleConfig struct {
MergeScheduleLimit uint64 `toml:"merge-schedule-limit,omitempty" json:"merge-schedule-limit"`
// TolerantSizeRatio is the ratio of buffer size for balance scheduler.
TolerantSizeRatio float64 `toml:"tolerant-size-ratio,omitempty" json:"tolerant-size-ratio"`
// LowSpaceRatio is the lowest available ratio of store which regraded as low space.
LowSpaceRatio float64 `toml:"low-space-ratio,omitempty" json:"low-space-ratio"`
// HighSpaceRatio is the highest available ratio of store which regraded as high space.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add some description about how does low space or high space affect balance algorithms.

@@ -103,15 +104,38 @@ func (s *StoreInfo) DownTime() time.Duration {
}

const minWeight = 1e-6
const maxScore = 10000
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can make it 100000.

func (s *StoreInfo) LeaderScore() float64 {
return float64(s.LeaderSize) / math.Max(s.LeaderWeight, minWeight)
func (s *StoreInfo) LeaderScore(highSpaceRatio, lowSpaceRatio float64) float64 {
return s.score(float64(s.LeaderSize), highSpaceRatio, lowSpaceRatio) / math.Max(s.LeaderWeight, minWeight)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does leader score need to consider storage space?

@Connor1996 Connor1996 changed the title [WIP] *: new score formula *: new score function Apr 18, 2018
var score float64

// lowSpaceRatio shouldn't greater than highSpaceRatio
if lowSpaceRatio > highSpaceRatio {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can check this in config adjustment.

Copy link
Member Author

Choose a reason for hiding this comment

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

using pd-ctl to set config will not call adjust()

Copy link
Contributor

Choose a reason for hiding this comment

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

lowSpaceRatio = highSpaceRatio will panic in the formula

Copy link
Member Author

Choose a reason for hiding this comment

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

when lowSpaceRatio == highSpaceRatio, it is impossible to run into else branch.

store.Stats.Capacity = uint64(1024)
store.Stats.Available = store.Stats.Capacity
store.Stats.Capacity = 1000 * (1 << 20)
store.Stats.Available = store.Stats.Capacity - uint64(store.LeaderSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

LeaderSize -> RegionSize?

lowSpaceRatio = highSpaceRatio
}

amplification := float64(s.RegionSize) / (float64(s.Stats.GetUsedSize()) / (1 << 20))
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment about what does amplification mean?

log "github.com/sirupsen/logrus"
)

type mockCluster struct {
*schedule.BasicCluster
// MockCluster is to mock clusterInfo for test use
Copy link
Contributor

Choose a reason for hiding this comment

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

is used to.

@disksing disksing added the priority/P1 The issue has P1 priority. label Apr 19, 2018
@Connor1996
Copy link
Member Author

I will add check config validation in other PR

Copy link
Contributor

@disksing disksing left a comment

Choose a reason for hiding this comment

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

LGTM.

@Connor1996 Connor1996 changed the title *: new score function *: new store region score function for balance Apr 19, 2018
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

LGTM

@Connor1996 Connor1996 merged commit e94ccf5 into tikv:master Apr 19, 2018
@Connor1996 Connor1996 deleted the new-formula branch April 19, 2018 07:20
disksing pushed a commit to oh-my-tidb/pd that referenced this pull request May 7, 2018
disksing added a commit that referenced this pull request May 8, 2018
* server: skip check a region if there is already a pending operator. (#1029)

* pdctl, api, schedule: pdctl supports scatter region. (#1028)

* add change log (#1024)

* scheduler: hot write scheduler randomly select the balance strategy (#1034)

* *: new store region score function for balance (#1014)

* core: adjust capacity to fit for more cases (#1035)

* check config validation (#1036)

* *: add metrics for hotspot cache (#1027)

* Refine install instructions. (#1041)

These extra steps can help new users who are perhaps not quite so familiar with Go setup and conventions.

* *: add change log for 2.0 GA (#1038)

* *: add change log for ga.

* scheduler: adjust metrics (#1042)

* fix parse error of config.toml (#1043)

* server: resign pd leader when it is not same as etcd leader. (#1039)

* server: fix the valid scheduler was deleted when start coordinator (#1045)

* server: fix the valid scheduler was deleted when start coordinator
ti-chi-bot pushed a commit that referenced this pull request Feb 15, 2023
…1.11.1 in /tools/pd-tso-bench (#5990)

ref #897, ref #962, ref #969, ref #974, ref #975, ref #976, ref #986, ref prometheus/client_golang#987, ref #987, ref #989, ref #998, ref #1013, ref #1014, ref #1025, ref #1028, ref #1031, ref #1043, ref #1055, ref #1075, ref #1091, ref #1094, ref #1102, ref #1103, ref #1118, ref #1146, ref #1148, ref #1150

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ti-chi-bot pushed a commit that referenced this pull request Feb 15, 2023
…1.11.1 in /tests/client (#5992)

ref #897, ref #962, ref #969, ref #974, ref #975, ref #976, ref #986, ref #987, ref prometheus/client_golang#987, ref #989, ref #998, ref #1013, ref #1014, ref #1025, ref #1028, ref #1031, ref #1043, ref #1055, ref #1075, ref #1091, ref #1094, ref #1102, ref #1103, ref #1118, ref #1146, ref #1148, ref #1150, ref #4399

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ti-chi-bot added a commit that referenced this pull request Feb 15, 2023
…1.11.1 in /tests/mcs (#5993)

ref #897, ref #962, ref #969, ref #974, ref #975, ref #976, ref #986, ref #987, ref prometheus/client_golang#987, ref #989, ref #998, ref #1013, ref #1014, ref #1025, ref #1028, ref #1031, ref #1043, ref #1055, ref #1075, ref #1091, ref #1094, ref #1102, ref #1103, ref #1118, ref #1146, ref #1148, ref #1150, ref #4399

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
ti-chi-bot added a commit that referenced this pull request Feb 15, 2023
…1.11.1 in /client (#5991)

ref #897, ref #962, ref #969, ref #974, ref #975, ref #976, ref #986, ref #987, ref prometheus/client_golang#987, ref #989, ref #998, ref #1013, ref #1014, ref #1025, ref #1028, ref #1031, ref #1043, ref #1055, ref #1075, ref #1091, ref #1094, ref #1102, ref #1103, ref #1118, ref #1146, ref #1148, ref #1150, ref #4399

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/P1 The issue has P1 priority.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants