mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
cmd/workload: filtergen exits on errors; filterperf collects them and writes error file
This commit is contained in:
parent
65051bd249
commit
013f01986f
2 changed files with 22 additions and 21 deletions
|
|
@ -40,7 +40,6 @@ var (
|
||||||
Action: filterGenCmd,
|
Action: filterGenCmd,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
filterQueryFileFlag,
|
filterQueryFileFlag,
|
||||||
filterErrorFileFlag,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
filterQueryFileFlag = &cli.StringFlag{
|
filterQueryFileFlag = &cli.StringFlag{
|
||||||
|
|
@ -73,8 +72,7 @@ func filterGenCmd(ctx *cli.Context) error {
|
||||||
query.run(f.client, nil)
|
query.run(f.client, nil)
|
||||||
if query.Err != nil {
|
if query.Err != nil {
|
||||||
query.printError()
|
query.printError()
|
||||||
f.errors = append(f.errors, query)
|
exit("filter query failed")
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
if len(query.results) > 0 && len(query.results) <= maxFilterResultSize {
|
if len(query.results) > 0 && len(query.results) <= maxFilterResultSize {
|
||||||
for {
|
for {
|
||||||
|
|
@ -92,8 +90,7 @@ func filterGenCmd(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
if extQuery.Err != nil {
|
if extQuery.Err != nil {
|
||||||
extQuery.printError()
|
extQuery.printError()
|
||||||
f.errors = append(f.errors, extQuery)
|
exit("filter query failed")
|
||||||
break
|
|
||||||
}
|
}
|
||||||
if len(extQuery.results) > maxFilterResultSize {
|
if len(extQuery.results) > maxFilterResultSize {
|
||||||
break
|
break
|
||||||
|
|
@ -103,7 +100,6 @@ func filterGenCmd(ctx *cli.Context) error {
|
||||||
f.storeQuery(query)
|
f.storeQuery(query)
|
||||||
if time.Since(lastWrite) > time.Second*10 {
|
if time.Since(lastWrite) > time.Second*10 {
|
||||||
f.writeQueries()
|
f.writeQueries()
|
||||||
f.writeErrors()
|
|
||||||
lastWrite = time.Now()
|
lastWrite = time.Now()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -114,18 +110,15 @@ func filterGenCmd(ctx *cli.Context) error {
|
||||||
type filterTestGen struct {
|
type filterTestGen struct {
|
||||||
client *client
|
client *client
|
||||||
queryFile string
|
queryFile string
|
||||||
errorFile string
|
|
||||||
|
|
||||||
finalizedBlock int64
|
finalizedBlock int64
|
||||||
queries [filterBuckets][]*filterQuery
|
queries [filterBuckets][]*filterQuery
|
||||||
errors []*filterQuery
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFilterTestGen(ctx *cli.Context) *filterTestGen {
|
func newFilterTestGen(ctx *cli.Context) *filterTestGen {
|
||||||
return &filterTestGen{
|
return &filterTestGen{
|
||||||
client: makeClient(ctx),
|
client: makeClient(ctx),
|
||||||
queryFile: ctx.String(filterQueryFileFlag.Name),
|
queryFile: ctx.String(filterQueryFileFlag.Name),
|
||||||
errorFile: ctx.String(filterErrorFileFlag.Name),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,17 +355,6 @@ func (s *filterTestGen) writeQueries() {
|
||||||
file.Close()
|
file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeQueries serializes the generated errors to the error file.
|
|
||||||
func (s *filterTestGen) writeErrors() {
|
|
||||||
file, err := os.Create(s.errorFile)
|
|
||||||
if err != nil {
|
|
||||||
exit(fmt.Errorf("Error creating filter error file %s: %v", s.errorFile, err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
json.NewEncoder(file).Encode(s.errors)
|
|
||||||
}
|
|
||||||
|
|
||||||
func mustGetFinalizedBlock(client *client) int64 {
|
func mustGetFinalizedBlock(client *client) int64 {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -61,7 +63,10 @@ func filterPerfCmd(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run test queries.
|
// Run test queries.
|
||||||
var failed, pruned, mismatch int
|
var (
|
||||||
|
failed, pruned, mismatch int
|
||||||
|
errors []*filterQuery
|
||||||
|
)
|
||||||
for i := 1; i <= passCount; i++ {
|
for i := 1; i <= passCount; i++ {
|
||||||
fmt.Println("Performance test pass", i, "/", passCount)
|
fmt.Println("Performance test pass", i, "/", passCount)
|
||||||
for len(queries) > 0 {
|
for len(queries) > 0 {
|
||||||
|
|
@ -80,11 +85,13 @@ func filterPerfCmd(ctx *cli.Context) error {
|
||||||
qt.medianTime = qt.runtime[len(qt.runtime)/2]
|
qt.medianTime = qt.runtime[len(qt.runtime)/2]
|
||||||
if qt.query.Err != nil {
|
if qt.query.Err != nil {
|
||||||
qt.query.printError()
|
qt.query.printError()
|
||||||
|
errors = append(errors, qt.query)
|
||||||
failed++
|
failed++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if rhash := qt.query.calculateHash(); *qt.query.ResultHash != rhash {
|
if rhash := qt.query.calculateHash(); *qt.query.ResultHash != rhash {
|
||||||
fmt.Printf("Filter query result mismatch: fromBlock: %d toBlock: %d addresses: %v topics: %v expected hash: %064x calculated hash: %064x\n", qt.query.FromBlock, qt.query.ToBlock, qt.query.Address, qt.query.Topics, *qt.query.ResultHash, rhash)
|
fmt.Printf("Filter query result mismatch: fromBlock: %d toBlock: %d addresses: %v topics: %v expected hash: %064x calculated hash: %064x\n", qt.query.FromBlock, qt.query.ToBlock, qt.query.Address, qt.query.Topics, *qt.query.ResultHash, rhash)
|
||||||
|
errors = append(errors, qt.query)
|
||||||
mismatch++
|
mismatch++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -127,6 +134,7 @@ func filterPerfCmd(ctx *cli.Context) error {
|
||||||
fmt.Printf("Most expensive query #%-2d median runtime: %13v max runtime: %13v result count: %4d fromBlock: %9d toBlock: %9d addresses: %v topics: %v\n",
|
fmt.Printf("Most expensive query #%-2d median runtime: %13v max runtime: %13v result count: %4d fromBlock: %9d toBlock: %9d addresses: %v topics: %v\n",
|
||||||
i+1, q.medianTime, q.runtime[len(q.runtime)-1], len(q.query.results), q.query.FromBlock, q.query.ToBlock, q.query.Address, q.query.Topics)
|
i+1, q.medianTime, q.runtime[len(q.runtime)-1], len(q.query.results), q.query.FromBlock, q.query.ToBlock, q.query.Address, q.query.Topics)
|
||||||
}
|
}
|
||||||
|
writeErrors(ctx.String(filterErrorFileFlag.Name), errors)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,3 +151,14 @@ func (st *bucketStats) print(name string) {
|
||||||
fmt.Printf("%-20s queries: %4d average block length: %12.2f average log count: %7.2f average runtime: %13v\n",
|
fmt.Printf("%-20s queries: %4d average block length: %12.2f average log count: %7.2f average runtime: %13v\n",
|
||||||
name, st.count, float64(st.blocks)/float64(st.count), float64(st.logs)/float64(st.count), st.runtime/time.Duration(st.count))
|
name, st.count, float64(st.blocks)/float64(st.count), float64(st.logs)/float64(st.count), st.runtime/time.Duration(st.count))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// writeQueries serializes the generated errors to the error file.
|
||||||
|
func writeErrors(errorFile string, errors []*filterQuery) {
|
||||||
|
file, err := os.Create(errorFile)
|
||||||
|
if err != nil {
|
||||||
|
exit(fmt.Errorf("Error creating filter error file %s: %v", errorFile, err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
json.NewEncoder(file).Encode(errors)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue