allow lotus-bench to benchmark existing sectorbuilders
This commit is contained in:
parent
19e57ab3ed
commit
5d12659266
@ -68,27 +68,41 @@ func main() {
|
|||||||
Name: "no-gpu",
|
Name: "no-gpu",
|
||||||
Usage: "disable gpu usage for the benchmark run",
|
Usage: "disable gpu usage for the benchmark run",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "benchmark-existing-sectorbuilder",
|
||||||
|
Usage: "pass a directory to run election-post timings on an existing sectorbuilder",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if c.Bool("no-gpu") {
|
if c.Bool("no-gpu") {
|
||||||
os.Setenv("BELLMAN_NO_GPU", "1")
|
os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
}
|
}
|
||||||
sdir, err := homedir.Expand(c.String("storage-dir"))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
os.MkdirAll(sdir, 0775)
|
robench := c.String("benchmark-existing-sectorbuilder")
|
||||||
|
|
||||||
tsdir, err := ioutil.TempDir(sdir, "bench")
|
var sbdir string
|
||||||
if err != nil {
|
|
||||||
return err
|
if robench == "" {
|
||||||
}
|
sdir, err := homedir.Expand(c.String("storage-dir"))
|
||||||
defer func() {
|
if err != nil {
|
||||||
if err := os.RemoveAll(tsdir); err != nil {
|
return err
|
||||||
log.Warn("remove all: ", err)
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
|
os.MkdirAll(sdir, 0775)
|
||||||
|
|
||||||
|
tsdir, err := ioutil.TempDir(sdir, "bench")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := os.RemoveAll(tsdir); err != nil {
|
||||||
|
log.Warn("remove all: ", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
sbdir = tsdir
|
||||||
|
} else {
|
||||||
|
sbdir = robench
|
||||||
|
}
|
||||||
|
|
||||||
maddr, err := address.NewFromString("t0101")
|
maddr, err := address.NewFromString("t0101")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -102,14 +116,17 @@ func main() {
|
|||||||
Miner: maddr,
|
Miner: maddr,
|
||||||
SectorSize: sectorSize,
|
SectorSize: sectorSize,
|
||||||
WorkerThreads: 2,
|
WorkerThreads: 2,
|
||||||
CacheDir: filepath.Join(tsdir, "cache"),
|
CacheDir: filepath.Join(sbdir, "cache"),
|
||||||
SealedDir: filepath.Join(tsdir, "sealed"),
|
SealedDir: filepath.Join(sbdir, "sealed"),
|
||||||
StagedDir: filepath.Join(tsdir, "staged"),
|
StagedDir: filepath.Join(sbdir, "staged"),
|
||||||
UnsealedDir: filepath.Join(tsdir, "unsealed"),
|
UnsealedDir: filepath.Join(sbdir, "unsealed"),
|
||||||
}
|
}
|
||||||
for _, d := range []string{cfg.CacheDir, cfg.SealedDir, cfg.StagedDir, cfg.UnsealedDir} {
|
|
||||||
if err := os.MkdirAll(d, 0775); err != nil {
|
if robench == "" {
|
||||||
return err
|
for _, d := range []string{cfg.CacheDir, cfg.SealedDir, cfg.StagedDir, cfg.UnsealedDir} {
|
||||||
|
if err := os.MkdirAll(d, 0775); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +143,7 @@ func main() {
|
|||||||
var sealTimings []SealingResult
|
var sealTimings []SealingResult
|
||||||
var sealedSectors []ffi.PublicSectorInfo
|
var sealedSectors []ffi.PublicSectorInfo
|
||||||
numSectors := uint64(1)
|
numSectors := uint64(1)
|
||||||
for i := uint64(1); i <= numSectors; i++ {
|
for i := uint64(1); i <= numSectors && robench == ""; i++ {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
log.Info("Writing piece into sector...")
|
log.Info("Writing piece into sector...")
|
||||||
|
|
||||||
@ -267,11 +284,13 @@ func main() {
|
|||||||
} // TODO: optionally write this as json to a file
|
} // TODO: optionally write this as json to a file
|
||||||
|
|
||||||
fmt.Println("results")
|
fmt.Println("results")
|
||||||
fmt.Printf("seal: addPiece: %s\n", benchout.SealingResults[0].AddPiece) // TODO: average across multiple sealings
|
if robench == "" {
|
||||||
fmt.Printf("seal: preCommit: %s\n", benchout.SealingResults[0].PreCommit)
|
fmt.Printf("seal: addPiece: %s\n", benchout.SealingResults[0].AddPiece) // TODO: average across multiple sealings
|
||||||
fmt.Printf("seal: Commit: %s\n", benchout.SealingResults[0].Commit)
|
fmt.Printf("seal: preCommit: %s\n", benchout.SealingResults[0].PreCommit)
|
||||||
fmt.Printf("seal: Verify: %s\n", benchout.SealingResults[0].Verify)
|
fmt.Printf("seal: Commit: %s\n", benchout.SealingResults[0].Commit)
|
||||||
fmt.Printf("unseal: %s\n", benchout.SealingResults[0].Unseal)
|
fmt.Printf("seal: Verify: %s\n", benchout.SealingResults[0].Verify)
|
||||||
|
fmt.Printf("unseal: %s\n", benchout.SealingResults[0].Unseal)
|
||||||
|
}
|
||||||
fmt.Printf("generate candidates: %s\n", benchout.PostGenerateCandidates)
|
fmt.Printf("generate candidates: %s\n", benchout.PostGenerateCandidates)
|
||||||
fmt.Printf("compute epost proof (cold): %s\n", benchout.PostEProofCold)
|
fmt.Printf("compute epost proof (cold): %s\n", benchout.PostEProofCold)
|
||||||
fmt.Printf("compute epost proof (hot): %s\n", benchout.PostEProofHot)
|
fmt.Printf("compute epost proof (hot): %s\n", benchout.PostEProofHot)
|
||||||
|
@ -204,6 +204,7 @@ var aggregateSectorDirsCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var aggrGenMiner genesis.GenesisMiner
|
||||||
var highestSectorID uint64
|
var highestSectorID uint64
|
||||||
for _, dir := range cctx.Args().Slice() {
|
for _, dir := range cctx.Args().Slice() {
|
||||||
dir, err := homedir.Expand(dir)
|
dir, err := homedir.Expand(dir)
|
||||||
@ -244,6 +245,8 @@ var aggregateSectorDirsCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aggrGenMiner = mergeGenMiners(aggrGenMiner, genm)
|
||||||
|
|
||||||
opts := badger.DefaultOptions
|
opts := badger.DefaultOptions
|
||||||
opts.ReadOnly = true
|
opts.ReadOnly = true
|
||||||
mds, err := badger.NewDatastore(filepath.Join(dir, "badger"), &opts)
|
mds, err := badger.NewDatastore(filepath.Join(dir, "badger"), &opts)
|
||||||
@ -274,6 +277,10 @@ var aggregateSectorDirsCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := seed.WriteGenesisMiner(maddr, destdir, &aggrGenMiner); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user