mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
1647bebaf4
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
27 lines
602 B
Go
27 lines
602 B
Go
package querynode
|
|
|
|
import (
|
|
"container/list"
|
|
)
|
|
|
|
type scheduleReadTaskPolicy func(sqTasks *list.List, targetUsage int32, maxNum int32) ([]readTask, int32)
|
|
|
|
func defaultScheduleReadPolicy(sqTasks *list.List, targetUsage int32, maxNum int32) ([]readTask, int32) {
|
|
var ret []readTask
|
|
usage := int32(0)
|
|
var next *list.Element
|
|
for e := sqTasks.Front(); e != nil && maxNum > 0; 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)
|
|
maxNum--
|
|
}
|
|
return ret, usage
|
|
}
|