Skip to content

Commit 878be92

Browse files
committed
Fix affinity bonus normalization in placement scoring
Normalize the affinity bonus by dividing it by totalCapacity to ensure the relative impact of the bonus is consistent across nodes of different sizes. Without normalization, the absolute affinity bonus has a disproportionately stronger effect on large nodes (where the base score is smaller) compared to small nodes, causing the algorithm to strongly prefer large nodes with cache affinity even when smaller nodes are less loaded.
1 parent 75d9d73 commit 878be92

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/api/internal/orchestrator/placement/placement_best_of_K.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (b *BestOfK) Score(node *nodemanager.Node, resources nodemanager.SandboxRes
6363

6464
score := (cpuRequested + float64(reserved) + config.Alpha*usageAvg) / totalCapacity
6565
if len(affinityScores) > 0 {
66-
score -= affinityScores[0][node.ID]
66+
score -= affinityScores[0][node.ID] / totalCapacity
6767
}
6868

6969
return score

0 commit comments

Comments
 (0)