Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sealing: load SectorsSummary from sealing SectorStats instead of calling API each time #11353

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# UNRELEASED
- chore: Auto remove local chain data when importing chain file or snapshot ([filecoin-project/lotus#11277](https://github.com/filecoin-project/lotus/pull/11277))
- feat: metric: export Mpool message count ([filecoin-project/lotus#11361](https://github.com/filecoin-project/lotus/pull/11361))
- feat: sealing: load SectorsSummary from sealing SectorStats instead of calling API each time ([filecoin-project/lotus#11353](https://github.com/filecoin-project/lotus/pull/11353))

## New features
- feat: Added new tracing API (**HIGHLY EXPERIMENTAL**) supporting two RPC methods: `trace_block` and `trace_replayBlockTransactions` ([filecoin-project/lotus#11100](https://github.com/filecoin-project/lotus/pull/11100))
Expand Down
14 changes: 2 additions & 12 deletions node/impl/storminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,9 @@ func (sm *StorageMinerAPI) SectorsListInStates(ctx context.Context, states []api
return sns, nil
}

// Use SectorsSummary from stats (prometheus) for faster result
func (sm *StorageMinerAPI) SectorsSummary(ctx context.Context) (map[api.SectorState]int, error) {
sectors, err := sm.Miner.ListSectors()
if err != nil {
return nil, err
}

out := make(map[api.SectorState]int)
for i := range sectors {
state := api.SectorState(sectors[i].State)
out[state]++
}

return out, nil
return sm.Miner.SectorsSummary(ctx), nil
}

func (sm *StorageMinerAPI) StorageLocal(ctx context.Context) (map[storiface.ID]string, error) {
Expand Down
14 changes: 14 additions & 0 deletions storage/pipeline/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ func (m *Sealing) TerminateSector(ctx context.Context, sid abi.SectorNumber) err
return m.sectors.Send(uint64(sid), SectorTerminate{})
}

func (m *Sealing) SectorsSummary(ctx context.Context) map[api.SectorState]int {
m.stats.lk.Lock()
defer m.stats.lk.Unlock()

out := make(map[api.SectorState]int)

for st, count := range m.stats.byState {
state := api.SectorState(st)
out[state] = int(count)
}

return out
}

func (m *Sealing) TerminateFlush(ctx context.Context) (*cid.Cid, error) {
return m.terminator.Flush(ctx)
}
Expand Down