From 5c27d6aeee59aff796d081b7479184c8532a4941 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 10:12:06 +0800 Subject: [PATCH 01/10] lotus-bench UnsealPiece SectorID.Number error --- cmd/lotus-bench/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index e409dfe5a0..b2b73710e9 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -614,7 +614,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par if !skipunseal { log.Infof("[%d] Unsealing sector", i) { - p, done, err := sbfs.AcquireSector(context.TODO(), abi.SectorID{Miner: mid, Number: 1}, stores.FTUnsealed, stores.FTNone, stores.PathSealing) + p, done, err := sbfs.AcquireSector(context.TODO(), abi.SectorID{Miner: mid, Number: i}, stores.FTUnsealed, stores.FTNone, stores.PathSealing) if err != nil { return xerrors.Errorf("acquire unsealed sector for removing: %w", err) } @@ -625,7 +625,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par } } - err := sb.UnsealPiece(context.TODO(), abi.SectorID{Miner: mid, Number: 1}, 0, abi.PaddedPieceSize(sectorSize).Unpadded(), ticket, cids.Unsealed) + err := sb.UnsealPiece(context.TODO(), abi.SectorID{Miner: mid, Number: i}, 0, abi.PaddedPieceSize(sectorSize).Unpadded(), ticket, cids.Unsealed) if err != nil { return err } From c99e223cb14b423bbfa0dee9e9668175053a7590 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 10:48:09 +0800 Subject: [PATCH 02/10] lotus bench change and add print --- cmd/lotus-bench/import.go | 2 +- cmd/lotus-bench/main.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index 3f99d0453b..1e6ce4352f 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -48,7 +48,7 @@ type TipSetExec struct { var importBenchCmd = &cli.Command{ Name: "import", - Usage: "benchmark chain import and validation", + Usage: "Benchmark chain import and validation", Subcommands: []*cli.Command{ importAnalyzeCmd, }, diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index b2b73710e9..b728aba330 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -94,7 +94,8 @@ func main() { } var sealBenchCmd = &cli.Command{ - Name: "sealing", + Name: "sealing", + Usage: "Benchmark seal and winning post and window post", Flags: []cli.Flag{ &cli.StringFlag{ Name: "storage-dir", @@ -428,7 +429,7 @@ var sealBenchCmd = &cli.Command{ fmt.Println(string(data)) } else { - fmt.Printf("----\nresults (v27) (%d)\n", sectorSize) + fmt.Printf("----\nresults (v28) (%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)) @@ -733,7 +734,7 @@ var proveCmd = &cli.Command{ fmt.Printf("proof: %x\n", proof) - fmt.Printf("----\nresults (v27) (%d)\n", c2in.SectorSize) + fmt.Printf("----\nresults (v28) (%d)\n", c2in.SectorSize) dur := sealCommit2.Sub(start) fmt.Printf("seal: commit phase 2: %s (%s)\n", dur, bps(abi.SectorSize(c2in.SectorSize), dur)) From c458f6e8261f9d60a21658d9d981bf92a020ecb0 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 11:25:19 +0800 Subject: [PATCH 03/10] lotus bench replace abi.SectorID with sid --- cmd/lotus-bench/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index b728aba330..cc0e191c75 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -591,7 +591,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par if !skipc2 { svi := saproof.SealVerifyInfo{ - SectorID: abi.SectorID{Miner: mid, Number: i}, + SectorID: sid, SealedCID: cids.Sealed, SealProof: sb.SealProofType(), Proof: proof, @@ -615,7 +615,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par if !skipunseal { log.Infof("[%d] Unsealing sector", i) { - p, done, err := sbfs.AcquireSector(context.TODO(), abi.SectorID{Miner: mid, Number: i}, stores.FTUnsealed, stores.FTNone, stores.PathSealing) + p, done, err := sbfs.AcquireSector(context.TODO(), sid, stores.FTUnsealed, stores.FTNone, stores.PathSealing) if err != nil { return xerrors.Errorf("acquire unsealed sector for removing: %w", err) } @@ -626,7 +626,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par } } - err := sb.UnsealPiece(context.TODO(), abi.SectorID{Miner: mid, Number: i}, 0, abi.PaddedPieceSize(sectorSize).Unpadded(), ticket, cids.Unsealed) + err := sb.UnsealPiece(context.TODO(), sid, 0, abi.PaddedPieceSize(sectorSize).Unpadded(), ticket, cids.Unsealed) if err != nil { return err } From c810b157cfed73555ae91247d084c55319e7e2ab Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 11:39:27 +0800 Subject: [PATCH 04/10] lotus bench delete ix --- cmd/lotus-bench/main.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index cc0e191c75..74c1f6b140 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -477,7 +477,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par return nil, nil, fmt.Errorf("parallelism factor must cleanly divide numSectors") } - for i := abi.SectorNumber(1); i <= abi.SectorNumber(numSectors); i++ { + for i := abi.SectorNumber(0); i < abi.SectorNumber(numSectors); i++ { sid := abi.SectorID{ Miner: mid, Number: i, @@ -495,7 +495,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par pieces = append(pieces, pi) - sealTimings[i-1].AddPiece = time.Since(start) + sealTimings[i].AddPiece = time.Since(start) } sectorsPerWorker := numSectors / par.PreCommit1 @@ -504,10 +504,9 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par for wid := 0; wid < par.PreCommit1; wid++ { go func(worker int) { sealerr := func() error { - start := 1 + (worker * sectorsPerWorker) + start := worker * sectorsPerWorker end := start + sectorsPerWorker for i := abi.SectorNumber(start); i < abi.SectorNumber(end); i++ { - ix := int(i - 1) sid := abi.SectorID{ Miner: mid, Number: i, @@ -519,8 +518,8 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par ticket := abi.SealRandomness(trand[:]) log.Infof("[%d] Running replication(1)...", i) - pieces := []abi.PieceInfo{pieces[ix]} - pc1o, err := sb.SealPreCommit1(context.TODO(), sid, ticket, pieces) + piece := []abi.PieceInfo{pieces[i]} + pc1o, err := sb.SealPreCommit1(context.TODO(), sid, ticket, piece) if err != nil { return xerrors.Errorf("commit: %w", err) } @@ -538,7 +537,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par precommit2 := time.Now() <-preCommit2Sema - sealedSectors[ix] = saproof.SectorInfo{ + sealedSectors[i] = saproof.SectorInfo{ SealProof: sb.SealProofType(), SectorNumber: i, SealedCID: cids.Sealed, @@ -552,7 +551,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par commitSema <- struct{}{} commitStart := time.Now() log.Infof("[%d] Generating PoRep for sector (1)", i) - c1o, err := sb.SealCommit1(context.TODO(), sid, ticket, seed.Value, pieces, cids) + c1o, err := sb.SealCommit1(context.TODO(), sid, ticket, seed.Value, piece, cids) if err != nil { return err } @@ -633,12 +632,12 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par } unseal := time.Now() - sealTimings[ix].PreCommit1 = precommit1.Sub(start) - sealTimings[ix].PreCommit2 = precommit2.Sub(pc2Start) - sealTimings[ix].Commit1 = sealcommit1.Sub(commitStart) - sealTimings[ix].Commit2 = sealcommit2.Sub(sealcommit1) - sealTimings[ix].Verify = verifySeal.Sub(sealcommit2) - sealTimings[ix].Unseal = unseal.Sub(verifySeal) + sealTimings[i].PreCommit1 = precommit1.Sub(start) + sealTimings[i].PreCommit2 = precommit2.Sub(pc2Start) + sealTimings[i].Commit1 = sealcommit1.Sub(commitStart) + sealTimings[i].Commit2 = sealcommit2.Sub(sealcommit1) + sealTimings[i].Verify = verifySeal.Sub(sealcommit2) + sealTimings[i].Unseal = unseal.Sub(verifySeal) } return nil }() From fcb9dea5018b579faa2aa7584ef4e2cce684ee68 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 16:31:39 +0800 Subject: [PATCH 05/10] add sum sealing time --- cmd/lotus-bench/main.go | 70 ++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 74c1f6b140..a324920291 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -39,8 +39,10 @@ import ( var log = logging.Logger("lotus-bench") type BenchResults struct { - SectorSize abi.SectorSize + SectorSize abi.SectorSize + SectorNumber abi.SectorNumber + SealingSum SealingResult SealingResults []SealingResult PostGenerateCandidates time.Duration @@ -55,6 +57,26 @@ type BenchResults struct { VerifyWindowPostHot time.Duration } +func (bo *BenchResults) SumSealingTime() error { + if len(bo.SealingResults) <= 0 { + return xerrors.Errorf("BenchResults SealingResults len <= 0") + } + if len(bo.SealingResults) != int(bo.SectorNumber) { + return xerrors.Errorf("BenchResults SealingResults len(%d) != bo.SectorNumber(%d)", len(bo.SealingResults), int(bo.SectorNumber)) + } + + for _, sealing := range bo.SealingResults { + bo.SealingSum.AddPiece += sealing.AddPiece + bo.SealingSum.PreCommit1 += sealing.PreCommit1 + bo.SealingSum.PreCommit2 += sealing.PreCommit2 + bo.SealingSum.Commit1 += sealing.Commit1 + bo.SealingSum.Commit2 += sealing.Commit2 + bo.SealingSum.Verify += sealing.Verify + bo.SealingSum.Unseal += sealing.Unseal + } + return nil +} + type SealingResult struct { AddPiece time.Duration PreCommit1 time.Duration @@ -237,6 +259,8 @@ var sealBenchCmd = &cli.Command{ return err } + sectorNumber := c.Int("num-sectors") + var sealTimings []SealingResult var sealedSectors []saproof.SectorInfo @@ -247,18 +271,11 @@ var sealBenchCmd = &cli.Command{ PreCommit2: 1, Commit: 1, } - sealTimings, sealedSectors, err = runSeals(sb, sbfs, c.Int("num-sectors"), parCfg, mid, sectorSize, []byte(c.String("ticket-preimage")), c.String("save-commit2-input"), c.Bool("skip-commit2"), c.Bool("skip-unseal")) + sealTimings, sealedSectors, err = runSeals(sb, sbfs, sectorNumber, parCfg, mid, sectorSize, []byte(c.String("ticket-preimage")), c.String("save-commit2-input"), c.Bool("skip-commit2"), c.Bool("skip-unseal")) if err != nil { return xerrors.Errorf("failed to run seals: %w", err) } - } - - beforePost := time.Now() - - var challenge [32]byte - rand.Read(challenge[:]) - - if robench != "" { + } else { // TODO: implement sbfs.List() and use that for all cases (preexisting sectorbuilder or not) // TODO: this assumes we only ever benchmark a preseal @@ -291,8 +308,17 @@ var sealBenchCmd = &cli.Command{ bo := BenchResults{ SectorSize: sectorSize, + SectorNumber: abi.SectorNumber(sectorNumber), SealingResults: sealTimings, } + if err := bo.SumSealingTime(); err != nil { + return err + } + + var challenge [32]byte + rand.Read(challenge[:]) + + beforePost := time.Now() if !c.Bool("skip-commit2") { log.Info("generating winning post candidates") @@ -429,16 +455,16 @@ var sealBenchCmd = &cli.Command{ fmt.Println(string(data)) } else { - fmt.Printf("----\nresults (v28) (%d)\n", sectorSize) + fmt.Printf("----\nresults (v28) SectorSize:(%d), SectorNumber:(%d)\n", sectorSize, sectorNumber) 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)) - fmt.Printf("seal: preCommit phase 2: %s (%s)\n", bo.SealingResults[0].PreCommit2, bps(bo.SectorSize, bo.SealingResults[0].PreCommit2)) - fmt.Printf("seal: commit phase 1: %s (%s)\n", bo.SealingResults[0].Commit1, bps(bo.SectorSize, bo.SealingResults[0].Commit1)) - fmt.Printf("seal: commit phase 2: %s (%s)\n", bo.SealingResults[0].Commit2, bps(bo.SectorSize, bo.SealingResults[0].Commit2)) - fmt.Printf("seal: verify: %s\n", bo.SealingResults[0].Verify) + fmt.Printf("seal: addPiece: %s (%s)\n", bo.SealingSum.AddPiece, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.AddPiece)) + fmt.Printf("seal: preCommit phase 1: %s (%s)\n", bo.SealingSum.PreCommit1, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit1)) + fmt.Printf("seal: preCommit phase 2: %s (%s)\n", bo.SealingSum.PreCommit2, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit2)) + fmt.Printf("seal: commit phase 1: %s (%s)\n", bo.SealingSum.Commit1, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit1)) + fmt.Printf("seal: commit phase 2: %s (%s)\n", bo.SealingSum.Commit2, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit2)) + fmt.Printf("seal: verify: %s\n", bo.SealingSum.Verify) if !c.Bool("skip-unseal") { - fmt.Printf("unseal: %s (%s)\n", bo.SealingResults[0].Unseal, bps(bo.SectorSize, bo.SealingResults[0].Unseal)) + fmt.Printf("unseal: %s (%s)\n", bo.SealingSum.Unseal, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Unseal)) } fmt.Println("") } @@ -747,3 +773,11 @@ func bps(data abi.SectorSize, d time.Duration) string { bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds())) return types.SizeStr(types.BigInt{Int: bps}) + "/s" } + +func bPS(sectorSize abi.SectorSize, sectorNum abi.SectorNumber, d time.Duration) string { + bdata := new(big.Int).SetUint64(uint64(sectorSize)) + bdata = bdata.Mul(bdata, new(big.Int).SetUint64(uint64(sectorNum))) + bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds())) + bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds())) + return types.SizeStr(types.BigInt{Int: bps}) + "/s" +} From e4209d86f680f73f661ed12f6d71801d3f3deca4 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 17:20:55 +0800 Subject: [PATCH 06/10] lotus bench add ticket-preimage --- cmd/lotus-bench/main.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index a324920291..8435aa9fa7 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -122,7 +122,7 @@ var sealBenchCmd = &cli.Command{ &cli.StringFlag{ Name: "storage-dir", Value: "~/.lotus-bench", - Usage: "Path to the storage directory that will store sectors long term", + Usage: "path to the storage directory that will store sectors long term", }, &cli.StringFlag{ Name: "sector-size", @@ -154,16 +154,22 @@ var sealBenchCmd = &cli.Command{ Name: "skip-unseal", Usage: "skip the unseal portion of the benchmark", }, + &cli.StringFlag{ + Name: "ticket-preimage", + Usage: "ticket random", + }, &cli.StringFlag{ Name: "save-commit2-input", - Usage: "Save commit2 input to a file", + Usage: "save commit2 input to a file", }, &cli.IntFlag{ Name: "num-sectors", + Usage: "select number of sectors to seal", Value: 1, }, &cli.IntFlag{ Name: "parallel", + Usage: "num run in parallel", Value: 1, }, }, @@ -244,7 +250,8 @@ var sealBenchCmd = &cli.Command{ } // Only fetch parameters if actually needed - if !c.Bool("skip-commit2") { + skipc2 := c.Bool("skip-commit2") + if !skipc2 { if err := paramfetch.GetParams(lcli.ReqContext(c), build.ParametersJSON(), uint64(sectorSize)); err != nil { return xerrors.Errorf("getting params: %w", err) } @@ -271,7 +278,7 @@ var sealBenchCmd = &cli.Command{ PreCommit2: 1, Commit: 1, } - sealTimings, sealedSectors, err = runSeals(sb, sbfs, sectorNumber, parCfg, mid, sectorSize, []byte(c.String("ticket-preimage")), c.String("save-commit2-input"), c.Bool("skip-commit2"), c.Bool("skip-unseal")) + sealTimings, sealedSectors, err = runSeals(sb, sbfs, sectorNumber, parCfg, mid, sectorSize, []byte(c.String("ticket-preimage")), c.String("save-commit2-input"), skipc2, c.Bool("skip-unseal")) if err != nil { return xerrors.Errorf("failed to run seals: %w", err) } @@ -320,7 +327,7 @@ var sealBenchCmd = &cli.Command{ beforePost := time.Now() - if !c.Bool("skip-commit2") { + if !skipc2 { log.Info("generating winning post candidates") wipt, err := spt.RegisteredWinningPoStProof() if err != nil { @@ -468,7 +475,7 @@ var sealBenchCmd = &cli.Command{ } fmt.Println("") } - if !c.Bool("skip-commit2") { + if !skipc2 { fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize*abi.SectorSize(len(bo.SealingResults)), bo.PostGenerateCandidates)) fmt.Printf("compute winning post proof (cold): %s\n", bo.PostWinningProofCold) fmt.Printf("compute winning post proof (hot): %s\n", bo.PostWinningProofHot) From c3a405eac73ce7afa7dfbda15b1faaecdd030e18 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 18:26:27 +0800 Subject: [PATCH 07/10] add lotus bench print --- cmd/lotus-bench/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 8435aa9fa7..dd4c0ab126 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -693,8 +693,9 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par } var proveCmd = &cli.Command{ - Name: "prove", - Usage: "Benchmark a proof computation", + Name: "prove", + Usage: "Benchmark a proof computation", + ArgsUsage: "[input.json]", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "no-gpu", @@ -755,6 +756,7 @@ var proveCmd = &cli.Command{ return err } + fmt.Printf("----\nstart proof computation\n") start := time.Now() proof, err := sb.SealCommit2(context.TODO(), abi.SectorID{Miner: abi.ActorID(mid), Number: abi.SectorNumber(c2in.SectorNum)}, c2in.Phase1Out) From bc1f18b73ae1fd12c05d3882cf9b97639461b508 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 11 Oct 2020 18:55:12 +0800 Subject: [PATCH 08/10] lotus bench optimize --- cmd/lotus-bench/main.go | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index dd4c0ab126..d5708386ce 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -40,7 +40,7 @@ var log = logging.Logger("lotus-bench") type BenchResults struct { SectorSize abi.SectorSize - SectorNumber abi.SectorNumber + SectorNumber int SealingSum SealingResult SealingResults []SealingResult @@ -315,7 +315,7 @@ var sealBenchCmd = &cli.Command{ bo := BenchResults{ SectorSize: sectorSize, - SectorNumber: abi.SectorNumber(sectorNumber), + SectorNumber: sectorNumber, SealingResults: sealTimings, } if err := bo.SumSealingTime(); err != nil { @@ -464,19 +464,19 @@ var sealBenchCmd = &cli.Command{ } else { fmt.Printf("----\nresults (v28) SectorSize:(%d), SectorNumber:(%d)\n", sectorSize, sectorNumber) if robench == "" { - fmt.Printf("seal: addPiece: %s (%s)\n", bo.SealingSum.AddPiece, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.AddPiece)) - fmt.Printf("seal: preCommit phase 1: %s (%s)\n", bo.SealingSum.PreCommit1, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit1)) - fmt.Printf("seal: preCommit phase 2: %s (%s)\n", bo.SealingSum.PreCommit2, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit2)) - fmt.Printf("seal: commit phase 1: %s (%s)\n", bo.SealingSum.Commit1, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit1)) - fmt.Printf("seal: commit phase 2: %s (%s)\n", bo.SealingSum.Commit2, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit2)) + fmt.Printf("seal: addPiece: %s (%s)\n", bo.SealingSum.AddPiece, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.AddPiece)) + fmt.Printf("seal: preCommit phase 1: %s (%s)\n", bo.SealingSum.PreCommit1, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit1)) + fmt.Printf("seal: preCommit phase 2: %s (%s)\n", bo.SealingSum.PreCommit2, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit2)) + fmt.Printf("seal: commit phase 1: %s (%s)\n", bo.SealingSum.Commit1, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit1)) + fmt.Printf("seal: commit phase 2: %s (%s)\n", bo.SealingSum.Commit2, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit2)) fmt.Printf("seal: verify: %s\n", bo.SealingSum.Verify) if !c.Bool("skip-unseal") { - fmt.Printf("unseal: %s (%s)\n", bo.SealingSum.Unseal, bPS(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Unseal)) + fmt.Printf("unseal: %s (%s)\n", bo.SealingSum.Unseal, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Unseal)) } fmt.Println("") } if !skipc2 { - fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize*abi.SectorSize(len(bo.SealingResults)), bo.PostGenerateCandidates)) + fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize, len(bo.SealingResults), bo.PostGenerateCandidates)) fmt.Printf("compute winning post proof (cold): %s\n", bo.PostWinningProofCold) fmt.Printf("compute winning post proof (hot): %s\n", bo.PostWinningProofHot) fmt.Printf("verify winning post proof (cold): %s\n", bo.VerifyWinningPostCold) @@ -771,21 +771,14 @@ var proveCmd = &cli.Command{ fmt.Printf("----\nresults (v28) (%d)\n", c2in.SectorSize) dur := sealCommit2.Sub(start) - fmt.Printf("seal: commit phase 2: %s (%s)\n", dur, bps(abi.SectorSize(c2in.SectorSize), dur)) + fmt.Printf("seal: commit phase 2: %s (%s)\n", dur, bps(abi.SectorSize(c2in.SectorSize), 1, dur)) return nil }, } -func bps(data abi.SectorSize, d time.Duration) string { - bdata := new(big.Int).SetUint64(uint64(data)) - bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds())) - bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds())) - return types.SizeStr(types.BigInt{Int: bps}) + "/s" -} - -func bPS(sectorSize abi.SectorSize, sectorNum abi.SectorNumber, d time.Duration) string { +func bps(sectorSize abi.SectorSize, sectorNum int, d time.Duration) string { bdata := new(big.Int).SetUint64(uint64(sectorSize)) - bdata = bdata.Mul(bdata, new(big.Int).SetUint64(uint64(sectorNum))) + bdata = bdata.Mul(bdata, big.NewInt(int64(sectorNum))) bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds())) bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds())) return types.SizeStr(types.BigInt{Int: bps}) + "/s" From 3e7efad0fd174961b028ce4d7ddd7bdcf29cbcf4 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Tue, 3 Nov 2020 21:28:01 +0800 Subject: [PATCH 09/10] modify lint error --- cmd/lotus-bench/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 62dd8c3fb8..0ca532d74d 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -61,8 +61,8 @@ func (bo *BenchResults) SumSealingTime() error { if len(bo.SealingResults) <= 0 { return xerrors.Errorf("BenchResults SealingResults len <= 0") } - if len(bo.SealingResults) != int(bo.SectorNumber) { - return xerrors.Errorf("BenchResults SealingResults len(%d) != bo.SectorNumber(%d)", len(bo.SealingResults), int(bo.SectorNumber)) + if len(bo.SealingResults) != bo.SectorNumber { + return xerrors.Errorf("BenchResults SealingResults len(%d) != bo.SectorNumber(%d)", len(bo.SealingResults), bo.SectorNumber) } for _, sealing := range bo.SealingResults { From d033042d6bc7c4c9d30b3949fa9a29895f33d35a Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Fri, 20 Nov 2020 23:20:26 +0800 Subject: [PATCH 10/10] update code --- cmd/lotus-bench/main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index d99b0d29be..b246aedbb3 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -501,7 +501,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par if numSectors%par.PreCommit1 != 0 { return nil, nil, fmt.Errorf("parallelism factor must cleanly divide numSectors") } - for i := abi.SectorNumber(1); i <= abi.SectorNumber(numSectors); i++ { + for i := abi.SectorNumber(0); i < abi.SectorNumber(numSectors); i++ { sid := storage.SectorRef{ ID: abi.SectorID{ Miner: mid, @@ -534,7 +534,6 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par start := worker * sectorsPerWorker end := start + sectorsPerWorker for i := abi.SectorNumber(start); i < abi.SectorNumber(end); i++ { - ix := int(i - 1) sid := storage.SectorRef{ ID: abi.SectorID{ Miner: mid, @@ -568,7 +567,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par precommit2 := time.Now() <-preCommit2Sema - sealedSectors[ix] = saproof2.SectorInfo{ + sealedSectors[i] = saproof2.SectorInfo{ SealProof: sid.ProofType, SectorNumber: i, SealedCID: cids.Sealed, @@ -621,7 +620,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par if !skipc2 { svi := saproof2.SealVerifyInfo{ - SectorID: sid, + SectorID: abi.SectorID{Miner: mid, Number: i}, SealedCID: cids.Sealed, SealProof: sid.ProofType, Proof: proof, @@ -745,8 +744,6 @@ var proveCmd = &cli.Command{ return err } - start := time.Now() - ref := storage.SectorRef{ ID: abi.SectorID{ Miner: abi.ActorID(mid),