enhance: some patches for #30636 (#30664)

Signed-off-by: sunby <sunbingyi1992@gmail.com>
pull/30817/head
Bingyi Sun 2024-02-26 11:42:55 +08:00 committed by GitHub
parent 9815cf50c9
commit ece9d273a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -96,7 +96,7 @@ func (m *segmentCountCostModel) cost() float64 {
return (currCost - best) / (worst - best)
}
func cmpFloat(f1, f2 float64) int {
func cmpCost(f1, f2 float64) int {
if math.Abs(f1-f2) < params.Params.QueryCoordCfg.BalanceCostThreshold.GetAsFloat() {
return 0
}
@ -279,7 +279,7 @@ func (g *rowCountBasedPlanGenerator) generatePlans() []SegmentAssignPlan {
newCluster := g.applyPlans(g.replicaNodeSegments, []SegmentAssignPlan{plan})
newGlobalCluster := g.applyPlans(g.globalNodeSegments, []SegmentAssignPlan{plan})
newCost := g.calClusterCost(newCluster, newGlobalCluster)
if cmpFloat(newCost, g.currClusterCost) < 0 {
if cmpCost(newCost, g.currClusterCost) < 0 {
g.currClusterCost = newCost
g.replicaNodeSegments = newCluster
g.globalNodeSegments = newGlobalCluster
@ -356,7 +356,7 @@ func (g *segmentCountBasedPlanGenerator) generatePlans() []SegmentAssignPlan {
newCluster := g.applyPlans(g.replicaNodeSegments, []SegmentAssignPlan{plan})
newGlobalCluster := g.applyPlans(g.globalNodeSegments, []SegmentAssignPlan{plan})
newCost := g.calClusterCost(newCluster, newGlobalCluster)
if cmpFloat(newCost, g.currClusterCost) < 0 {
if cmpCost(newCost, g.currClusterCost) < 0 {
g.currClusterCost = newCost
g.replicaNodeSegments = newCluster
g.globalNodeSegments = newGlobalCluster
@ -440,7 +440,7 @@ func (g *randomPlanGenerator) generatePlans() []SegmentAssignPlan {
newCluster := g.applyPlans(g.replicaNodeSegments, plans)
newGlobalCluster := g.applyPlans(g.globalNodeSegments, plans)
newCost := g.calClusterCost(newCluster, newGlobalCluster)
if cmpFloat(newCost, g.currClusterCost) < 0 {
if cmpCost(newCost, g.currClusterCost) < 0 {
g.currClusterCost = newCost
g.replicaNodeSegments = newCluster
g.globalNodeSegments = newGlobalCluster

View File

@ -1606,10 +1606,10 @@ func (p *queryCoordConfig) init(base *BaseTable) {
p.BalanceCostThreshold = ParamItem{
Key: "queryCoord.balanceCostThreshold",
Version: "2.3.5",
Version: "2.4.0",
DefaultValue: "0.001",
PanicIfEmpty: true,
Doc: "the threshold of balance cost",
Doc: "the threshold of balance cost, if the difference of cluster's cost after executing the balance plan is less than this value, the plan will not be executed",
Export: true,
}
p.BalanceCostThreshold.Init(base.mgr)