sched: Correct allocated resource accounting in spread assigner

This commit is contained in:
Łukasz Magiera 2022-05-23 22:22:27 +02:00
parent fd8b91a5d4
commit f2c2993164

View File

@ -16,10 +16,13 @@ func SpreadWS(sh *Scheduler, queueLen int, acceptableWindows [][]int, windows []
scheduled := 0 scheduled := 0
rmQueue := make([]int, 0, queueLen) rmQueue := make([]int, 0, queueLen)
workerAssigned := map[storiface.WorkerID]int{} workerAssigned := map[storiface.WorkerID]int{}
for sqi := 0; sqi < queueLen; sqi++ { for sqi := 0; sqi < queueLen; sqi++ {
task := (*sh.SchedQueue)[sqi] task := (*sh.SchedQueue)[sqi]
selectedWindow := -1 selectedWindow := -1
var needRes storiface.Resources
var info storiface.WorkerInfo
var bestWid storiface.WorkerID var bestWid storiface.WorkerID
bestAssigned := math.MaxInt // smaller = better bestAssigned := math.MaxInt // smaller = better
@ -40,6 +43,8 @@ func SpreadWS(sh *Scheduler, queueLen int, acceptableWindows [][]int, windows []
continue continue
} }
info = w.Info
needRes = res
bestWid = wid bestWid = wid
selectedWindow = wnd selectedWindow = wnd
bestAssigned = wu bestAssigned = wu
@ -59,6 +64,7 @@ func SpreadWS(sh *Scheduler, queueLen int, acceptableWindows [][]int, windows []
"assigned", bestAssigned) "assigned", bestAssigned)
workerAssigned[bestWid]++ workerAssigned[bestWid]++
windows[selectedWindow].Allocated.Add(info.Resources, needRes)
windows[selectedWindow].Todo = append(windows[selectedWindow].Todo, task) windows[selectedWindow].Todo = append(windows[selectedWindow].Todo, task)
rmQueue = append(rmQueue, sqi) rmQueue = append(rmQueue, sqi)