cli: Show separate worker types in miner info
This commit is contained in:
parent
36f1dd7bb3
commit
5365ccfdb1
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
||||||
"math"
|
"math"
|
||||||
corebig "math/big"
|
corebig "math/big"
|
||||||
"os"
|
"os"
|
||||||
@ -343,6 +344,38 @@ func handleMiningInfo(ctx context.Context, cctx *cli.Context, fullapi v0api.Full
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
ws, err := nodeApi.WorkerStats(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting worker stats: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var nseal, nwdpost, nwinpost int
|
||||||
|
|
||||||
|
wloop:
|
||||||
|
for _, st := range ws {
|
||||||
|
if !st.Enabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, task := range st.Tasks {
|
||||||
|
if task == sealtasks.TTGenerateWindowPoSt {
|
||||||
|
nwdpost++
|
||||||
|
continue wloop
|
||||||
|
}
|
||||||
|
if task == sealtasks.TTGenerateWinningPoSt {
|
||||||
|
nwinpost++
|
||||||
|
continue wloop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nseal++
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Workers: Seal(%d) WdPoSt(%d) WinPoSt(%d)\n", nseal, nwdpost, nwinpost)
|
||||||
|
}
|
||||||
|
|
||||||
if cctx.IsSet("blocks") {
|
if cctx.IsSet("blocks") {
|
||||||
fmt.Println("Produced newest blocks:")
|
fmt.Println("Produced newest blocks:")
|
||||||
err = producedBlocks(ctx, cctx.Int("blocks"), maddr, fullapi)
|
err = producedBlocks(ctx, cctx.Int("blocks"), maddr, fullapi)
|
||||||
@ -350,9 +383,6 @@ func handleMiningInfo(ctx context.Context, cctx *cli.Context, fullapi v0api.Full
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: grab actr state / info
|
|
||||||
// * Sealed sectors (count / bytes)
|
|
||||||
// * Power
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
4
extern/sector-storage/sched_post.go
vendored
4
extern/sector-storage/sched_post.go
vendored
@ -223,10 +223,10 @@ func (ps *poStScheduler) schedClose() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *poStScheduler) WorkerStats(cb func(wid storiface.WorkerID, worker *workerHandle)) {
|
func (ps *poStScheduler) WorkerStats(ctx context.Context, cb func(ctx context.Context, wid storiface.WorkerID, worker *workerHandle)) {
|
||||||
ps.lk.RLock()
|
ps.lk.RLock()
|
||||||
defer ps.lk.RUnlock()
|
defer ps.lk.RUnlock()
|
||||||
for id, w := range ps.workers {
|
for id, w := range ps.workers {
|
||||||
cb(id, w)
|
cb(ctx, id, w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
extern/sector-storage/stats.go
vendored
27
extern/sector-storage/stats.go
vendored
@ -1,22 +1,39 @@
|
|||||||
package sectorstorage
|
package sectorstorage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *Manager) WorkerStats() map[uuid.UUID]storiface.WorkerStats {
|
func (m *Manager) WorkerStats(ctx context.Context) map[uuid.UUID]storiface.WorkerStats {
|
||||||
m.sched.workersLk.RLock()
|
m.sched.workersLk.RLock()
|
||||||
|
|
||||||
out := map[uuid.UUID]storiface.WorkerStats{}
|
out := map[uuid.UUID]storiface.WorkerStats{}
|
||||||
|
|
||||||
cb := func(id storiface.WorkerID, handle *workerHandle) {
|
cb := func(ctx context.Context, id storiface.WorkerID, handle *workerHandle) {
|
||||||
handle.lk.Lock()
|
handle.lk.Lock()
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
tt, err := handle.workerRpc.TaskTypes(ctx)
|
||||||
|
var taskList []sealtasks.TaskType
|
||||||
|
if err != nil {
|
||||||
|
log.Warnw("getting worker task types in WorkerStats", "error", err)
|
||||||
|
} else {
|
||||||
|
for taskType := range tt {
|
||||||
|
taskList = append(taskList, taskType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out[uuid.UUID(id)] = storiface.WorkerStats{
|
out[uuid.UUID(id)] = storiface.WorkerStats{
|
||||||
Info: handle.info,
|
Info: handle.info,
|
||||||
|
Tasks: taskList,
|
||||||
Enabled: handle.enabled,
|
Enabled: handle.enabled,
|
||||||
MemUsedMin: handle.active.memUsedMin,
|
MemUsedMin: handle.active.memUsedMin,
|
||||||
MemUsedMax: handle.active.memUsedMax,
|
MemUsedMax: handle.active.memUsedMax,
|
||||||
@ -27,14 +44,14 @@ func (m *Manager) WorkerStats() map[uuid.UUID]storiface.WorkerStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for id, handle := range m.sched.workers {
|
for id, handle := range m.sched.workers {
|
||||||
cb(id, handle)
|
cb(ctx, id, handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.sched.workersLk.RUnlock()
|
m.sched.workersLk.RUnlock()
|
||||||
|
|
||||||
//list post workers
|
//list post workers
|
||||||
m.winningPoStSched.WorkerStats(cb)
|
m.winningPoStSched.WorkerStats(ctx, cb)
|
||||||
m.windowPoStSched.WorkerStats(cb)
|
m.windowPoStSched.WorkerStats(ctx, cb)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
extern/sector-storage/storiface/worker.go
vendored
1
extern/sector-storage/storiface/worker.go
vendored
@ -68,6 +68,7 @@ func (wr WorkerResources) ResourceSpec(spt abi.RegisteredSealProof, tt sealtasks
|
|||||||
|
|
||||||
type WorkerStats struct {
|
type WorkerStats struct {
|
||||||
Info WorkerInfo
|
Info WorkerInfo
|
||||||
|
Tasks []sealtasks.TaskType
|
||||||
Enabled bool
|
Enabled bool
|
||||||
|
|
||||||
MemUsedMin uint64
|
MemUsedMin uint64
|
||||||
|
@ -131,8 +131,8 @@ func (sm *StorageMinerAPI) ServeRemote(perm bool) func(w http.ResponseWriter, r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) WorkerStats(context.Context) (map[uuid.UUID]storiface.WorkerStats, error) {
|
func (sm *StorageMinerAPI) WorkerStats(ctx context.Context) (map[uuid.UUID]storiface.WorkerStats, error) {
|
||||||
return sm.StorageMgr.WorkerStats(), nil
|
return sm.StorageMgr.WorkerStats(ctx), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) WorkerJobs(ctx context.Context) (map[uuid.UUID][]storiface.WorkerJob, error) {
|
func (sm *StorageMinerAPI) WorkerJobs(ctx context.Context) (map[uuid.UUID][]storiface.WorkerJob, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user