From 0d2d0067ca859394139a3cf6b1cf8fa8e1f3db64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 15 Oct 2021 21:26:35 +0200 Subject: [PATCH] Show prepared tasks in sealing jobs --- cmd/lotus-miner/sealing.go | 4 +++- extern/sector-storage/stats.go | 8 ++++++- extern/sector-storage/storiface/worker.go | 5 ++++- extern/sector-storage/worker_tracked.go | 27 ++++++++++++++--------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/cmd/lotus-miner/sealing.go b/cmd/lotus-miner/sealing.go index a7e0a8de8dd..472af8da61d 100644 --- a/cmd/lotus-miner/sealing.go +++ b/cmd/lotus-miner/sealing.go @@ -224,8 +224,10 @@ var sealingJobsCmd = &cli.Command{ for _, l := range lines { state := "running" switch { - case l.RunWait > 0: + case l.RunWait > 1: state = fmt.Sprintf("assigned(%d)", l.RunWait-1) + case l.RunWait == storiface.RWPrepared: + state = "prepared" case l.RunWait == storiface.RWRetDone: if !cctx.Bool("show-ret-done") { continue diff --git a/extern/sector-storage/stats.go b/extern/sector-storage/stats.go index 7103e878c5a..43828742a4b 100644 --- a/extern/sector-storage/stats.go +++ b/extern/sector-storage/stats.go @@ -35,7 +35,13 @@ func (m *Manager) WorkerJobs() map[uuid.UUID][]storiface.WorkerJob { out := map[uuid.UUID][]storiface.WorkerJob{} calls := map[storiface.CallID]struct{}{} - for _, t := range m.sched.workTracker.Running() { + running, preparing := m.sched.workTracker.Running() + + for _, t := range running { + out[uuid.UUID(t.worker)] = append(out[uuid.UUID(t.worker)], t.job) + calls[t.job.ID] = struct{}{} + } + for _, t := range preparing { out[uuid.UUID(t.worker)] = append(out[uuid.UUID(t.worker)], t.job) calls[t.job.ID] = struct{}{} } diff --git a/extern/sector-storage/storiface/worker.go b/extern/sector-storage/storiface/worker.go index d1373f4c541..e3374d6cf86 100644 --- a/extern/sector-storage/storiface/worker.go +++ b/extern/sector-storage/storiface/worker.go @@ -47,6 +47,8 @@ type WorkerStats struct { } const ( + RWPrepared = 1 + RWRunning = 0 RWRetWait = -1 RWReturned = -2 RWRetDone = -3 @@ -57,7 +59,8 @@ type WorkerJob struct { Sector abi.SectorID Task sealtasks.TaskType - // 1+ - assigned + // 2+ - assigned + // 1 - prepared // 0 - running // -1 - ret-wait // -2 - returned diff --git a/extern/sector-storage/worker_tracked.go b/extern/sector-storage/worker_tracked.go index 8be1976fa01..03ae292587a 100644 --- a/extern/sector-storage/worker_tracked.go +++ b/extern/sector-storage/worker_tracked.go @@ -72,13 +72,14 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke return callID, err } - tracked := func() trackedWork { + tracked := func(rw int) trackedWork { return trackedWork{ job: storiface.WorkerJob{ - ID: callID, - Sector: sid.ID, - Task: task, - Start: time.Now(), + ID: callID, + Sector: sid.ID, + Task: task, + Start: time.Now(), + RunWait: rw, }, worker: wid, workerHostname: wi.Hostname, @@ -90,7 +91,7 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke case <-ctx.Done(): return callID, ctx.Err() default: - wt.prepared[callID] = tracked() + wt.prepared[callID] = tracked(storiface.RWPrepared) wt.lk.Unlock() select { @@ -111,7 +112,7 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke delete(wt.prepared, callID) } - wt.running[callID] = tracked() + wt.running[callID] = tracked(storiface.RWRunning) ctx, _ = tag.New( ctx, @@ -136,16 +137,20 @@ func (wt *workTracker) worker(wid WorkerID, wi storiface.WorkerInfo, w Worker) * } } -func (wt *workTracker) Running() []trackedWork { +func (wt *workTracker) Running() ([]trackedWork, []trackedWork) { wt.lk.Lock() defer wt.lk.Unlock() - out := make([]trackedWork, 0, len(wt.running)) + running := make([]trackedWork, 0, len(wt.running)) for _, job := range wt.running { - out = append(out, job) + running = append(running, job) + } + prepared := make([]trackedWork, 0, len(wt.prepared)) + for _, job := range wt.prepared { + prepared = append(prepared, job) } - return out + return running, prepared } type trackedWorker struct {