bench: Option to skip commit2

This commit is contained in:
Łukasz Magiera 2020-03-15 18:48:27 +01:00
parent 1bc55714ed
commit 630df050c0

View File

@ -13,16 +13,17 @@ import (
"time"
"github.com/docker/go-units"
paramfetch "github.com/filecoin-project/go-paramfetch"
"github.com/filecoin-project/go-sectorbuilder/fs"
"github.com/filecoin-project/specs-actors/actors/abi"
logging "github.com/ipfs/go-log/v2"
"github.com/mitchellh/go-homedir"
"golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/go-address"
paramfetch "github.com/filecoin-project/go-paramfetch"
"github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/go-sectorbuilder/fs"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-storage/storage"
lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
@ -102,6 +103,10 @@ func main() {
Name: "json-out",
Usage: "output results in json format",
},
&cli.BoolFlag{
Name: "skip-commit2",
Usage: "skip the commit2 (snark) portion of the benchmark",
},
&cli.BoolFlag{
Name: "skip-unseal",
Usage: "skip the unseal portion of the benchmark",
@ -174,9 +179,11 @@ func main() {
}
}
if !c.Bool("skip-commit2") {
if err := paramfetch.GetParams(build.ParametersJson(), uint64(sectorSize)); err != nil {
return xerrors.Errorf("getting params: %w", err)
}
}
sbfs := &fs.Basic{
Miner: maddr,
@ -269,13 +276,18 @@ func main() {
}
}
proof, err := sb.SealCommit2(context.TODO(), i, c1o)
var proof storage.Proof
if !c.Bool("skip-commit2") {
proof, err = sb.SealCommit2(context.TODO(), i, c1o)
if err != nil {
return err
}
}
sealcommit2 := time.Now()
if !c.Bool("skip-commit2") {
svi := abi.SealVerifyInfo{
SectorID: abi.SectorID{Miner: mid, Number: i},
OnChain: abi.OnChainSealVerifyInfo{
@ -299,11 +311,13 @@ func main() {
if !ok {
return xerrors.Errorf("porep proof for sector %d was invalid", i)
}
}
verifySeal := time.Now()
if !c.Bool("skip-unseal") {
log.Info("Unsealing sector")
// TODO: RM unsealed sector first
rc, err := sb.ReadPieceFromSealedSector(context.TODO(), 1, 0, abi.UnpaddedPieceSize(sectorSize), ticket, commD)
if err != nil {
return err
@ -359,6 +373,12 @@ func main() {
}
}
bo := BenchResults{
SectorSize: sectorSize,
SealingResults: sealTimings,
}
if !c.Bool("skip-commit2") {
log.Info("generating election post candidates")
fcandidates, err := sb.GenerateEPostCandidates(sealedSectors, challenge[:], []abi.SectorNumber{})
if err != nil {
@ -427,16 +447,13 @@ func main() {
}
verifypost2 := time.Now()
bo := BenchResults{
SectorSize: sectorSize,
SealingResults: sealTimings,
bo.PostGenerateCandidates = gencandidates.Sub(beforePost)
bo.PostEProofCold = epost1.Sub(gencandidates)
bo.PostEProofHot = epost2.Sub(epost1)
bo.VerifyEPostCold = verifypost1.Sub(epost2)
bo.VerifyEPostHot = verifypost2.Sub(verifypost1)
}
PostGenerateCandidates: gencandidates.Sub(beforePost),
PostEProofCold: epost1.Sub(gencandidates),
PostEProofHot: epost2.Sub(epost1),
VerifyEPostCold: verifypost1.Sub(epost2),
VerifyEPostHot: verifypost2.Sub(verifypost1),
} // TODO: optionally write this as json to a file
if c.Bool("json-out") {
data, err := json.MarshalIndent(bo, "", " ")
@ -446,7 +463,7 @@ func main() {
fmt.Println(string(data))
} else {
fmt.Printf("----\nresults (v23) (%d)\n", sectorSize)
fmt.Printf("----\nresults (v24) (%d)\n", sectorSize)
if robench == "" {
fmt.Printf("seal: addPiece: %s (%s)\n", bo.SealingResults[0].AddPiece, bps(bo.SectorSize, bo.SealingResults[0].AddPiece)) // TODO: average across multiple sealings
fmt.Printf("seal: preCommit phase 1: %s (%s)\n", bo.SealingResults[0].PreCommit1, bps(bo.SectorSize, bo.SealingResults[0].PreCommit1))
@ -458,12 +475,14 @@ func main() {
fmt.Printf("unseal: %s (%s)\n", bo.SealingResults[0].Unseal, bps(bo.SectorSize, bo.SealingResults[0].Unseal))
}
}
if !c.Bool("skip-commit2") {
fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize*abi.SectorSize(len(bo.SealingResults)), bo.PostGenerateCandidates))
fmt.Printf("compute epost proof (cold): %s\n", bo.PostEProofCold)
fmt.Printf("compute epost proof (hot): %s\n", bo.PostEProofHot)
fmt.Printf("verify epost proof (cold): %s\n", bo.VerifyEPostCold)
fmt.Printf("verify epost proof (hot): %s\n", bo.VerifyEPostHot)
}
}
return nil
},
}