sealing sched: Give more priority to tasks (re)moving data

This commit is contained in:
Łukasz Magiera 2020-08-27 23:28:52 +02:00
parent f2bd680cc5
commit 7fdffc0340
2 changed files with 20 additions and 9 deletions

View File

@ -7,6 +7,11 @@ type requestQueue []*workerRequest
func (q requestQueue) Len() int { return len(q) }
func (q requestQueue) Less(i, j int) bool {
oneMuchLess, muchLess := q[i].taskType.MuchLess(q[j].taskType)
if oneMuchLess {
return muchLess
}
if q[i].priority != q[j].priority {
return q[i].priority > q[j].priority
}

View File

@ -17,15 +17,15 @@ const (
)
var order = map[TaskType]int{
TTAddPiece: 7,
TTPreCommit1: 6,
TTPreCommit2: 5,
TTCommit2: 4,
TTCommit1: 3,
TTFetch: 2,
TTFinalize: 1,
TTUnseal: 0,
TTReadUnsealed: 0,
TTAddPiece: 6, // least priority
TTPreCommit1: 5,
TTPreCommit2: 4,
TTCommit2: 3,
TTCommit1: 2,
TTUnseal: 1,
TTFetch: -1,
TTReadUnsealed: -1,
TTFinalize: -2, // most priority
}
var shortNames = map[TaskType]string{
@ -43,6 +43,12 @@ var shortNames = map[TaskType]string{
TTReadUnsealed: "RD ",
}
func (a TaskType) MuchLess(b TaskType) (bool, bool) {
oa, ob := order[a], order[b]
oneNegative := oa^ob < 0
return oneNegative, oa < ob
}
func (a TaskType) Less(b TaskType) bool {
return order[a] < order[b]
}