enhance: Enhance the load balancing of import tasks (#31423)

Optimize the load balancing of import tasks.

issue: https://github.com/milvus-io/milvus/issues/31232

---------

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/31003/head
yihao.dai 2024-03-21 10:21:06 +08:00 committed by GitHub
parent d0dd962a2f
commit c725f95885
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 5 deletions

View File

@ -88,13 +88,20 @@ func (s *importScheduler) Close() {
func (s *importScheduler) process() {
getNodeID := func(nodeSlots map[int64]int64) int64 {
for nodeID, slots := range nodeSlots {
if slots > 0 {
nodeSlots[nodeID]--
return nodeID
var (
nodeID int64 = NullNodeID
maxSlots int64 = -1
)
for id, slots := range nodeSlots {
if slots > 0 && slots > maxSlots {
nodeID = id
maxSlots = slots
}
}
return NullNodeID
if nodeID != NullNodeID {
nodeSlots[nodeID]--
}
return nodeID
}
jobs := s.imeta.GetJobBy()