sectorstorage: Don't require tasks within a window to run in order
This commit is contained in:
parent
11b11e416b
commit
4a75e1e4b4
26
extern/sector-storage/sched.go
vendored
26
extern/sector-storage/sched.go
vendored
@ -566,21 +566,31 @@ func (sh *scheduler) runWorker(wid WorkerID) {
|
|||||||
assignLoop:
|
assignLoop:
|
||||||
// process windows in order
|
// process windows in order
|
||||||
for len(worker.activeWindows) > 0 {
|
for len(worker.activeWindows) > 0 {
|
||||||
// process tasks within a window in order
|
firstWindow := worker.activeWindows[0]
|
||||||
for len(worker.activeWindows[0].todo) > 0 {
|
|
||||||
todo := worker.activeWindows[0].todo[0]
|
|
||||||
needRes := ResourceTable[todo.taskType][sh.spt]
|
|
||||||
|
|
||||||
|
// process tasks within a window, preferring tasks at lower indexes
|
||||||
|
for len(firstWindow.todo) > 0 {
|
||||||
sh.workersLk.RLock()
|
sh.workersLk.RLock()
|
||||||
|
|
||||||
|
tidx := -1
|
||||||
|
|
||||||
worker.lk.Lock()
|
worker.lk.Lock()
|
||||||
ok := worker.preparing.canHandleRequest(needRes, wid, worker.info.Resources)
|
for t, todo := range firstWindow.todo {
|
||||||
|
needRes := ResourceTable[todo.taskType][sh.spt]
|
||||||
|
if worker.preparing.canHandleRequest(needRes, wid, worker.info.Resources) {
|
||||||
|
tidx = t
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
worker.lk.Unlock()
|
worker.lk.Unlock()
|
||||||
|
|
||||||
if !ok {
|
if tidx == -1 {
|
||||||
sh.workersLk.RUnlock()
|
sh.workersLk.RUnlock()
|
||||||
break assignLoop
|
break assignLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
todo := firstWindow.todo[tidx]
|
||||||
|
|
||||||
log.Debugf("assign worker sector %d", todo.sector.Number)
|
log.Debugf("assign worker sector %d", todo.sector.Number)
|
||||||
err := sh.assignWorker(taskDone, wid, worker, todo)
|
err := sh.assignWorker(taskDone, wid, worker, todo)
|
||||||
sh.workersLk.RUnlock()
|
sh.workersLk.RUnlock()
|
||||||
@ -591,7 +601,9 @@ func (sh *scheduler) runWorker(wid WorkerID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: we're not freeing window.allocated resources here very much on purpose
|
// Note: we're not freeing window.allocated resources here very much on purpose
|
||||||
worker.activeWindows[0].todo = worker.activeWindows[0].todo[1:]
|
copy(firstWindow.todo[tidx:], firstWindow.todo[tidx+1:])
|
||||||
|
firstWindow.todo[len(firstWindow.todo)-1] = nil
|
||||||
|
firstWindow.todo = firstWindow.todo[:len(firstWindow.todo)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(worker.activeWindows, worker.activeWindows[1:])
|
copy(worker.activeWindows, worker.activeWindows[1:])
|
||||||
|
Loading…
Reference in New Issue
Block a user