enhance: make balance cost threshold configurable (#30636)

Signed-off-by: sunby <sunbingyi1992@gmail.com>
pull/30502/head
Bingyi Sun 2024-02-19 15:24:50 +08:00 committed by GitHub
parent 3ee13d9b20
commit 564b12c661
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 1 deletions

View File

@ -53,6 +53,7 @@ var (
RoundRobinBalancerName = "RoundRobinBalancer"
RowCountBasedBalancerName = "RowCountBasedBalancer"
ScoreBasedBalancerName = "ScoreBasedBalancer"
MultiTargetBalancerName = "MultipleTargetBalancer"
)
type Balance interface {

View File

@ -97,7 +97,7 @@ func (m *segmentCountCostModel) cost() float64 {
}
func cmpFloat(f1, f2 float64) int {
if math.Abs(f1-f2) < 0.001 {
if math.Abs(f1-f2) < params.Params.QueryCoordCfg.BalanceCostThreshold.GetAsFloat() {
return 0
}
if f1 < f2 {

View File

@ -282,6 +282,8 @@ func (s *Server) initQueryCoord() error {
s.nodeMgr, s.dist, s.meta, s.targetMgr)
s.balancerMap[balance.ScoreBasedBalancerName] = balance.NewScoreBasedBalancer(s.taskScheduler,
s.nodeMgr, s.dist, s.meta, s.targetMgr)
s.balancerMap[balance.MultiTargetBalancerName] = balance.NewMultiTargetBalancer(s.taskScheduler, s.nodeMgr, s.dist, s.meta, s.targetMgr)
if balancer, ok := s.balancerMap[params.Params.QueryCoordCfg.Balancer.GetValue()]; ok {
s.balancer = balancer
log.Info("use config balancer", zap.String("balancer", params.Params.QueryCoordCfg.Balancer.GetValue()))

View File

@ -1369,6 +1369,7 @@ type queryCoordConfig struct {
RowCountMaxSteps ParamItem `refreshable:"true"`
RandomMaxSteps ParamItem `refreshable:"true"`
GrowingRowCountWeight ParamItem `refreshable:"true"`
BalanceCostThreshold ParamItem `refreshable:"true"`
SegmentCheckInterval ParamItem `refreshable:"true"`
ChannelCheckInterval ParamItem `refreshable:"true"`
@ -1596,6 +1597,16 @@ func (p *queryCoordConfig) init(base *BaseTable) {
}
p.GrowingRowCountWeight.Init(base.mgr)
p.BalanceCostThreshold = ParamItem{
Key: "queryCoord.balanceCostThreshold",
Version: "2.3.5",
DefaultValue: "0.001",
PanicIfEmpty: true,
Doc: "the threshold of balance cost",
Export: true,
}
p.BalanceCostThreshold.Init(base.mgr)
p.MemoryUsageMaxDifferencePercentage = ParamItem{
Key: "queryCoord.memoryUsageMaxDifferencePercentage",
Version: "2.0.0",