fix sched_test
This commit is contained in:
parent
5881edb75e
commit
5a458a60c2
@ -2,7 +2,6 @@ package sealer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"sync"
|
||||
@ -10,6 +9,7 @@ import (
|
||||
"go.opencensus.io/stats"
|
||||
|
||||
"github.com/filecoin-project/lotus/metrics"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
)
|
||||
|
||||
type WindowSelector func(sh *Scheduler, queueLen int, acceptableWindows [][]int, windows []SchedWindow) int
|
||||
|
@ -1,9 +1,10 @@
|
||||
package sealer
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type ActiveResources struct {
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
prooftypes "github.com/filecoin-project/go-state-types/proof"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/storage/paths"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
|
||||
@ -587,18 +588,24 @@ func TestSched(t *testing.T) {
|
||||
|
||||
type slowishSelector bool
|
||||
|
||||
func (s slowishSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, a *WorkerHandle) (bool, bool, error) {
|
||||
time.Sleep(200 * time.Microsecond)
|
||||
func (s slowishSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, a SchedWorker) (bool, bool, error) {
|
||||
_, _ = a.Paths(ctx)
|
||||
_, _ = a.TaskTypes(ctx)
|
||||
return bool(s), false, nil
|
||||
}
|
||||
|
||||
func (s slowishSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *WorkerHandle) (bool, error) {
|
||||
time.Sleep(100 * time.Microsecond)
|
||||
func (s slowishSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b SchedWorker) (bool, error) {
|
||||
_, _ = a.Paths(ctx)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
var _ WorkerSelector = slowishSelector(true)
|
||||
|
||||
type tw struct {
|
||||
api.Worker
|
||||
io.Closer
|
||||
}
|
||||
|
||||
func BenchmarkTrySched(b *testing.B) {
|
||||
logging.SetAllLoggers(logging.LevelInfo)
|
||||
defer logging.SetAllLoggers(logging.LevelDebug)
|
||||
@ -609,14 +616,25 @@ func BenchmarkTrySched(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
b.StopTimer()
|
||||
|
||||
var whnd api.WorkerStruct
|
||||
whnd.Internal.TaskTypes = func(p0 context.Context) (map[sealtasks.TaskType]struct{}, error) {
|
||||
time.Sleep(100 * time.Microsecond)
|
||||
return nil, nil
|
||||
}
|
||||
whnd.Internal.Paths = func(p0 context.Context) ([]storiface.StoragePath, error) {
|
||||
time.Sleep(100 * time.Microsecond)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
sched, err := newScheduler(ctx, "")
|
||||
require.NoError(b, err)
|
||||
sched.Workers[storiface.WorkerID{}] = &WorkerHandle{
|
||||
workerRpc: nil,
|
||||
workerRpc: &tw{Worker: &whnd},
|
||||
Info: storiface.WorkerInfo{
|
||||
Hostname: "t",
|
||||
Resources: decentWorkerResources,
|
||||
},
|
||||
Enabled: true,
|
||||
preparing: NewActiveResources(),
|
||||
active: NewActiveResources(),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user