-
Notifications
You must be signed in to change notification settings - Fork 724
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
Conversation
server/core/store.go
Outdated
return maxScore - available | ||
} | ||
|
||
k := (maxScore - (lowSpaceRatio+highSpaceRatio)*capacity) / ((1 - lowSpaceRatio - highSpaceRatio) * capacity) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
server/core/store.go
Outdated
@@ -103,15 +104,38 @@ func (s *StoreInfo) DownTime() time.Duration { | |||
} | |||
|
|||
const minWeight = 1e-6 | |||
const maxScore = 10000 |
There was a problem hiding this comment.
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.
server/core/store.go
Outdated
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) |
There was a problem hiding this comment.
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?
server/core/store.go
Outdated
var score float64 | ||
|
||
// lowSpaceRatio shouldn't greater than highSpaceRatio | ||
if lowSpaceRatio > highSpaceRatio { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
server/coordinator_test.go
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LeaderSize -> RegionSize?
server/core/store.go
Outdated
lowSpaceRatio = highSpaceRatio | ||
} | ||
|
||
amplification := float64(s.RegionSize) / (float64(s.Stats.GetUsedSize()) / (1 << 20)) |
There was a problem hiding this comment.
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?
server/schedule/mockcluster.go
Outdated
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
type mockCluster struct { | ||
*schedule.BasicCluster | ||
// MockCluster is to mock clusterInfo for test use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is used to.
I will add check config validation in other PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 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
…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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ti Chi Robot <[email protected]>
…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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ti Chi Robot <[email protected]>
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.