-
Notifications
You must be signed in to change notification settings - Fork 20.8k
cmd/workload: fixed filter test request error handling #31424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,10 @@ | |
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"math/rand" | ||
"os" | ||
"slices" | ||
"sort" | ||
"time" | ||
|
@@ -41,7 +43,7 @@ var ( | |
} | ||
) | ||
|
||
const passCount = 1 | ||
const passCount = 3 | ||
|
||
func filterPerfCmd(ctx *cli.Context) error { | ||
cfg := testConfigFromCLI(ctx) | ||
|
@@ -61,7 +63,10 @@ func filterPerfCmd(ctx *cli.Context) error { | |
} | ||
|
||
// Run test queries. | ||
var failed, mismatch int | ||
var ( | ||
failed, pruned, mismatch int | ||
errors []*filterQuery | ||
) | ||
for i := 1; i <= passCount; i++ { | ||
fmt.Println("Performance test pass", i, "/", passCount) | ||
for len(queries) > 0 { | ||
|
@@ -71,27 +76,35 @@ func filterPerfCmd(ctx *cli.Context) error { | |
queries = queries[:len(queries)-1] | ||
start := time.Now() | ||
qt.query.run(cfg.client, cfg.historyPruneBlock) | ||
if qt.query.Err == errPrunedHistory { | ||
pruned++ | ||
continue | ||
} | ||
qt.runtime = append(qt.runtime, time.Since(start)) | ||
slices.Sort(qt.runtime) | ||
qt.medianTime = qt.runtime[len(qt.runtime)/2] | ||
if qt.query.Err != nil { | ||
qt.query.printError() | ||
errors = append(errors, qt.query) | ||
failed++ | ||
continue | ||
} | ||
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) | ||
errors = append(errors, qt.query) | ||
mismatch++ | ||
continue | ||
} | ||
processed = append(processed, qt) | ||
if len(processed)%50 == 0 { | ||
fmt.Println(" processed:", len(processed), "remaining", len(queries), "failed:", failed, "result mismatch:", mismatch) | ||
fmt.Println(" processed:", len(processed), "remaining", len(queries), "failed:", failed, "pruned:", pruned, "result mismatch:", mismatch) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, we should replace |
||
} | ||
} | ||
queries, processed = processed, nil | ||
} | ||
|
||
// Show results and stats. | ||
fmt.Println("Performance test finished; processed:", len(queries), "failed:", failed, "result mismatch:", mismatch) | ||
fmt.Println("Performance test finished; processed:", len(queries), "failed:", failed, "pruned:", pruned, "result mismatch:", mismatch) | ||
stats := make([]bucketStats, len(f.queries)) | ||
var wildcardStats bucketStats | ||
for _, qt := range queries { | ||
|
@@ -114,11 +127,14 @@ func filterPerfCmd(ctx *cli.Context) error { | |
sort.Slice(queries, func(i, j int) bool { | ||
return queries[i].medianTime > queries[j].medianTime | ||
}) | ||
for i := 0; i < 10; i++ { | ||
q := queries[i] | ||
for i, q := range queries { | ||
if i >= 10 { | ||
break | ||
} | ||
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) | ||
} | ||
writeErrors(ctx.String(filterErrorFileFlag.Name), errors) | ||
return nil | ||
} | ||
|
||
|
@@ -135,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", | ||
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) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crap. big oversight on my part.. whoops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was correct at some point. I must have inadvertently broken it before my original PR was merged.