Skip to content

Commit

Permalink
Show prepared tasks in sealing jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 18, 2021
1 parent 8f0d68e commit 0d2d006
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
4 changes: 3 additions & 1 deletion cmd/lotus-miner/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion extern/sector-storage/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
}
Expand Down
5 changes: 4 additions & 1 deletion extern/sector-storage/storiface/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type WorkerStats struct {
}

const (
RWPrepared = 1
RWRunning = 0
RWRetWait = -1
RWReturned = -2
RWRetDone = -3
Expand All @@ -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
Expand Down
27 changes: 16 additions & 11 deletions extern/sector-storage/worker_tracked.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 0d2d006

Please sign in to comment.