Skip to content

Commit

Permalink
feat: refine miner_sector_deal_v2 performance issue (#1300)
Browse files Browse the repository at this point in the history
* Integrate sectorNumber to dealState and get the sectorID

* Use dealProposal to find the providerID
  • Loading branch information
Terryhung authored May 16, 2024
1 parent 661d756 commit 8273f89
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 44 deletions.
3 changes: 2 additions & 1 deletion chain/actors/builtin/market/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type State interface {
DealStatesAmtBitwidth() int

GetProviderSectors() (map[abi.SectorID][]abi.DealID, error)
GetProviderSectorsByDealID(map[abi.DealID]bool) (map[abi.DealID]abi.SectorID, error)
GetProviderSectorsByDealID(map[abi.DealID]bool, map[abi.SectorNumber]bool) (map[abi.DealID]abi.SectorID, error)
}

type BalanceTable interface {
Expand Down Expand Up @@ -106,6 +106,7 @@ type DealProposal = markettypes.DealProposal
type DealLabel = markettypes.DealLabel

type DealState interface {
SectorNumber() abi.SectorNumber
SectorStartEpoch() abi.ChainEpoch // -1 if not yet included in proven sector
LastUpdatedEpoch() abi.ChainEpoch // -1 if deal state never updated
SlashEpoch() abi.ChainEpoch // -1 if deal never slashed
Expand Down
7 changes: 6 additions & 1 deletion chain/actors/builtin/market/market.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion chain/actors/builtin/market/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func (d dealStateV{{.v}}) SectorStartEpoch() abi.ChainEpoch {
return d.ds{{.v}}.SectorStartEpoch
}

func (d dealStateV{{.v}}) SectorNumber() abi.SectorNumber {
{{if ge .v 13}}
return d.ds{{.v}}.SectorNumber
{{else}}
return 0
{{end}}
}

func (d dealStateV{{.v}}) LastUpdatedEpoch() abi.ChainEpoch {
return d.ds{{.v}}.LastUpdatedEpoch
}
Expand Down Expand Up @@ -348,7 +356,7 @@ func (s *state{{.v}}) GetProviderSectors() (map[abi.SectorID][]abi.DealID, error
{{end}}
}

func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool) (map[abi.DealID]abi.SectorID, error) {
func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool, sectorIDMap map[abi.SectorNumber]bool) (map[abi.DealID]abi.SectorID, error) {
{{if (le .v 12)}}
return nil, nil
{{else}}
Expand Down Expand Up @@ -376,6 +384,10 @@ func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool)
return err
}

if _, found := sectorIDMap[abi.SectorNumber(sectorNumber)]; !found {
return nil
}

dealIDsCopy := make([]abi.DealID, len(dealIDs))
copy(dealIDsCopy, dealIDs)

Expand Down
8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v0.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v10.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v11.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v12.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion chain/actors/builtin/market/v13.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v3.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v4.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v5.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v6.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v7.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v8.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v9.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lens/util/builtinactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package util
import (
"strconv"

"github.com/filecoin-project/lotus/chain/types"
"github.com/fxamacker/cbor/v2"
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/ipld/go-ipld-prime/node/basicnode"
"github.com/ipld/go-ipld-prime/node/bindnode"

"github.com/filecoin-project/lotus/chain/types"
)

type KVEvent struct {
Expand Down
Loading

0 comments on commit 8273f89

Please sign in to comment.