From 7ef1b62b4187bed73ff3936f54477e4b423cef5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 2 Sep 2021 19:27:10 +0200 Subject: [PATCH] sealing: Fix sector state accounting with FinalizeEarly --- extern/storage-sealing/sector_state.go | 12 ++++++++++-- extern/storage-sealing/stats.go | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/extern/storage-sealing/sector_state.go b/extern/storage-sealing/sector_state.go index deb5e9f28e6..34a0c6bbef8 100644 --- a/extern/storage-sealing/sector_state.go +++ b/extern/storage-sealing/sector_state.go @@ -106,11 +106,19 @@ const ( Removed SectorState = "Removed" ) -func toStatState(st SectorState) statSectorState { +func toStatState(st SectorState, finEarly bool) statSectorState { switch st { case UndefinedSectorState, Empty, WaitDeals, AddPiece: return sstStaging - case Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, SubmitPreCommitBatch, PreCommitBatchWait, WaitSeed, Committing, CommitFinalize, SubmitCommit, CommitWait, SubmitCommitAggregate, CommitAggregateWait, FinalizeSector: + case Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, SubmitPreCommitBatch, PreCommitBatchWait, WaitSeed, Committing, CommitFinalize, FinalizeSector: + return sstSealing + case SubmitCommit, CommitWait, SubmitCommitAggregate, CommitAggregateWait: + if finEarly { + // we use statSectorState for throttling storage use. With FinalizeEarly + // we can consider sectors in states after CommitFinalize as finalized, so + // that more sectors can enter the sealing pipeline (and later be aggregated together) + return sstProving + } return sstSealing case Proving, Removed, Removing, Terminating, TerminateWait, TerminateFinality, TerminateFailed: return sstProving diff --git a/extern/storage-sealing/stats.go b/extern/storage-sealing/stats.go index 2688d849405..28556866a20 100644 --- a/extern/storage-sealing/stats.go +++ b/extern/storage-sealing/stats.go @@ -37,7 +37,7 @@ func (ss *SectorStats) updateSector(cfg sealiface.Config, id abi.SectorID, st Se ss.totals[oldst]-- } - sst := toStatState(st) + sst := toStatState(st, cfg.FinalizeEarly) ss.bySector[id] = sst ss.totals[sst]++