diff --git a/storage/sealer/sched.go b/storage/sealer/sched.go index 1a1b0fdb9b1..c2b7d6a2d67 100644 --- a/storage/sealer/sched.go +++ b/storage/sealer/sched.go @@ -87,7 +87,7 @@ type Scheduler struct { type WorkerHandle struct { workerRpc Worker - + Info storiface.WorkerInfo preparing *ActiveResources // use with WorkerHandle.lk diff --git a/storage/sealer/sched_assigner_common.go b/storage/sealer/sched_assigner_common.go index c0d7455e3f2..e6dd0956812 100644 --- a/storage/sealer/sched_assigner_common.go +++ b/storage/sealer/sched_assigner_common.go @@ -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 diff --git a/storage/sealer/sched_resources.go b/storage/sealer/sched_resources.go index 232e86e524d..487e294a22c 100644 --- a/storage/sealer/sched_resources.go +++ b/storage/sealer/sched_resources.go @@ -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 { diff --git a/storage/sealer/sched_test.go b/storage/sealer/sched_test.go index b52b8520a53..6818671f22d 100644 --- a/storage/sealer/sched_test.go +++ b/storage/sealer/sched_test.go @@ -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(), }