diff --git a/sched.go b/sched.go index 3822a8683..d7745da36 100644 --- a/sched.go +++ b/sched.go @@ -51,14 +51,14 @@ func newScheduler(spt abi.RegisteredProof) *scheduler { nextWorker: 0, workers: map[WorkerID]*workerHandle{}, - newWorkers: make(chan *workerHandle), + newWorkers: make(chan *workerHandle), watchClosing: make(chan WorkerID), workerClosing: make(chan WorkerID), - schedule: make(chan *workerRequest), - workerFree: make(chan WorkerID), - closing: make(chan struct{}), + schedule: make(chan *workerRequest), + workerFree: make(chan WorkerID), + closing: make(chan struct{}), schedQueue: list.New(), } @@ -394,7 +394,7 @@ func canHandleRequest(needRes Resources, spt abi.RegisteredProof, wid WorkerID, return false } } else { - if active.cpuUse + uint64(needRes.Threads) > res.CPUs { + if active.cpuUse+uint64(needRes.Threads) > res.CPUs { log.Debugf("sched: not scheduling on worker %d; not enough threads, need %d, %d in use, target %d", wid, needRes.Threads, active.cpuUse, res.CPUs) return false } @@ -416,12 +416,12 @@ func (a *activeResources) utilization(wr storiface.WorkerResources) float64 { cpu := float64(a.cpuUse) / float64(wr.CPUs) max = cpu - memMin := float64(a.memUsedMin + wr.MemReserved) / float64(wr.MemPhysical) + memMin := float64(a.memUsedMin+wr.MemReserved) / float64(wr.MemPhysical) if memMin > max { max = memMin } - memMax := float64(a.memUsedMax + wr.MemReserved) / float64(wr.MemPhysical + wr.MemSwap) + memMax := float64(a.memUsedMax+wr.MemReserved) / float64(wr.MemPhysical+wr.MemSwap) if memMax > max { max = memMax } diff --git a/sched_watch.go b/sched_watch.go index c2716aae9..214489083 100644 --- a/sched_watch.go +++ b/sched_watch.go @@ -68,7 +68,7 @@ func (sh *scheduler) runWorkerWatcher() { } cases[toSet] = reflect.SelectCase{ - Dir: reflect.SelectRecv, + Dir: reflect.SelectRecv, Chan: reflect.ValueOf(workerClosing), } @@ -78,7 +78,7 @@ func (sh *scheduler) runWorkerWatcher() { delete(caseToWorker, n) cases[n] = reflect.SelectCase{ - Dir: reflect.SelectRecv, + Dir: reflect.SelectRecv, Chan: nilch, } diff --git a/stores/remote.go b/stores/remote.go index 863bee083..a750d4841 100644 --- a/stores/remote.go +++ b/stores/remote.go @@ -27,7 +27,7 @@ type Remote struct { index SectorIndex auth http.Header - fetchLk sync.Mutex + fetchLk sync.Mutex fetching map[abi.SectorID]chan struct{} } @@ -121,7 +121,7 @@ func (r *Remote) acquireFromRemote(ctx context.Context, s abi.SectorID, fileType return "", "", "", nil, xerrors.Errorf("failed to acquire sector %v from remote(%d): not found", s, fileType) } - sort.Slice(si, func(i, j int) bool { + sort.Slice(si, func(i, j int) bool { return si[i].Weight < si[j].Weight })