mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 04:49:08 +08:00
ac6394d0fd
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
26 lines
549 B
Go
26 lines
549 B
Go
package querynode
|
|
|
|
import (
|
|
"container/list"
|
|
)
|
|
|
|
type scheduleReadTaskPolicy func(sqTasks *list.List, targetUsage int32) ([]readTask, int32)
|
|
|
|
func defaultScheduleReadPolicy(sqTasks *list.List, targetUsage int32) ([]readTask, int32) {
|
|
var ret []readTask
|
|
usage := int32(0)
|
|
var next *list.Element
|
|
for e := sqTasks.Front(); e != nil; e = next {
|
|
next = e.Next()
|
|
t, _ := e.Value.(readTask)
|
|
tUsage := t.CPUUsage()
|
|
if usage+tUsage > targetUsage {
|
|
break
|
|
}
|
|
usage += tUsage
|
|
sqTasks.Remove(e)
|
|
ret = append(ret, t)
|
|
}
|
|
return ret, usage
|
|
}
|