-
Notifications
You must be signed in to change notification settings - Fork 861
Add scenario capability to benchmark script #2779
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
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2779 +/- ##
==========================================
+ Coverage 47.10% 56.73% +9.62%
==========================================
Files 1939 2014 +75
Lines 159389 165422 +6033
==========================================
+ Hits 75086 93856 +18770
+ Misses 77799 63367 -14432
- Partials 6504 8199 +1695
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| for hash := range g.pendingDeploys { | ||
| hashes = append(hashes, hash) | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map Warning test
|
|
||
| // Initialize lastFlushTime on first increment (when blocks actually start processing) | ||
| if l.lastFlushTime.IsZero() { | ||
| l.lastFlushTime = time.Now() |
Check warning
Code scanning / CodeQL
Calling the system time Warning test
| func (l *Logger) StartBlockProcessing() { | ||
| l.mx.Lock() | ||
| defer l.mx.Unlock() | ||
| l.blockProcessStartTime = time.Now() |
Check warning
Code scanning / CodeQL
Calling the system time Warning test
|
|
||
| // FlushLog outputs the current statistics. | ||
| func (l *Logger) FlushLog() { | ||
| now := time.Now() |
Check warning
Code scanning / CodeQL
Calling the system time Warning test
| } | ||
|
|
||
| benchLogger := NewLogger(logger) | ||
| go benchLogger.Start(ctx) |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note test
| go func() { | ||
| defer close(ch) | ||
| for { | ||
| if ctx.Err() != nil { | ||
| return | ||
| } | ||
|
|
||
| txRecords := g.Generate() | ||
| if len(txRecords) == 0 { | ||
| continue | ||
| } | ||
|
|
||
| proposal := &abci.ResponsePrepareProposal{ | ||
| TxRecords: txRecords, | ||
| } | ||
|
|
||
| select { | ||
| case ch <- proposal: | ||
| case <-ctx.Done(): | ||
| return | ||
| } | ||
| } | ||
| }() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note test
| if duration <= 0 { | ||
| return 0 | ||
| } | ||
| return float64(txCount) / duration.Seconds() |
Check notice
Code scanning / CodeQL
Floating point arithmetic Note test
| NewAccountRate: cfg.Accounts.NewAccountRate, | ||
| }) | ||
| bg.accountPools = append(bg.accountPools, bg.sharedAccounts) | ||
| } |
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.
Sorry for a naive question, when would cfg.Accounts be nil? How do you generate traffic with no shared account pool?
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.
by default the load generator library generates a new account on every send if for some reason this is nil
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.
That seems a bit inefficient, is that really frequently in use?
| }, nil | ||
| } | ||
|
|
||
| // ProcessReceipts handles receipts from FinalizeBlock to extract deployed addresses. |
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.
nit: FinalizeBlock sounds like it's the block containing results at the end...
| } | ||
|
|
||
| // ProcessReceipts handles receipts from FinalizeBlock to extract deployed addresses. | ||
| func (g *Generator) ProcessReceipts(receipts map[common.Hash]*evmtypes.Receipt) { |
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.
nit: Can rename to something else which makes it obvious we are extracting deployed addresses?
| "gasUsed", receipt.GasUsed) | ||
|
|
||
| // Attach the deployed address to the scenario | ||
| if err := state.scenario.Attach(g.cfg, addr); err != nil { |
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.
Can we set deployed to true if this happens?
app/benchmark/generator.go
Outdated
| "vmError", receipt.VmError, | ||
| "gasUsed", receipt.GasUsed) | ||
| // Remove from pending but don't mark as deployed | ||
| delete(g.pendingDeploys, txHash) |
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.
Will this make allDeployed always fail?
| weightedConfigs := make([]*generator.WeightedCfg, 0, len(g.scenarios)) | ||
| for _, state := range g.scenarios { | ||
| if !state.deployed { | ||
| g.logger.Info("benchmark: Scenario not deployed, skipping", "scenario", state.config.Name) |
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.
I guess you could panic here as well, because we checked that all scenarios are deployed before entering this function.
| // If money is conserved, this should be zero | ||
| // useiPreTotal - useiPostTotal = how much usei left balances (negative means usei entered balances) | ||
| // weiDiffInUsei = how much usei was moved to wei balances | ||
| // supplyChanged = how much new usei was minted |
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.
How is this comment related tothis PR?
| if !useiDiff.IsZero() { | ||
| panic(fmt.Sprintf("unexpected usei balance total found! Pre-block usei total %s wei total %s total supply %s, post-block usei total %s wei total %s total supply %s", useiPreTotal, weiPreTotal, preTotalSupply, useiPostTotal, weiPostTotal, preTotalSupply.Add(supplyChanged))) | ||
| } | ||
| app.Logger().Info("successfully verified supply light invariance") |
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.
Removed because this isn't a useful log?
| // ensureMinimumBalance tops off the account if balance is low. | ||
| // Called from GetBalance to ensure preCheck passes in StateTransition. | ||
| func (s *DBImpl) ensureMinimumBalance(evmAddr common.Address) { | ||
| if s.ctx.ChainID() == "pacific-1" { |
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.
I think you use evmcfg.IsLiveEVMChainID(evmChainID) elsewhere?
| if err != nil { | ||
| s.err = err | ||
| } | ||
| _ = s.k.BankKeeper().SendCoinsAndWei(ctx, moduleAddr, seiAddr, usei, wei) |
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.
Should you log this error maybe?
| BENCHMARK_TXS_PER_BATCH=$BENCHMARK_TXS_PER_BATCH ~/go/bin/seid start --chain-id sei-chain 2>&1 | grep benchmark | ||
| if [ "$DEBUG" = true ]; then | ||
| # Debug mode: print all output | ||
| BENCHMARK_CONFIG=$BENCHMARK_CONFIG BENCHMARK_TXS_PER_BATCH=$BENCHMARK_TXS_PER_BATCH ~/go/bin/seid start --chain-id sei-chain |
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.
nit: could chain-id uses something more obvious it's a benchmark?
* main: Composite State Store part 1: EVM config and type definitions (#2754) Add scenario capability to benchmark script (#2779) emit rewards withdrawn events for redelegate/undelegate (#2781) add original cachekv as base layer (#2780) Add Ethereum state test runner for Giga executor validation (#2707) Add changelog for 6.2 and 6.3 (#2751) Fix typo in backport CI workflow name (#2784) Upgrade to latest UCI workflows (#2783) Configure self-hosted runners for Go tests (#2715)
Summary
Adds configurable scenario support to the benchmark script, enabling ERC20 and other contract-based load testing scenarios. (Fyi the benchmark won't really perform fully until the storage + autobahn changes are in, but this tooling now operates)
Changes
New Benchmark Package (
app/benchmark/)app/benchmark.goto a dedicated packageScenario Configuration (
scripts/scenarios/)erc20.json- ERC20 token transfer benchmark (5000 accounts)EVMTransfer.json- Simple native transfersmixed.json- Combined workload exampleREADME.md- DocumentationMock Balance Fixes (
giga/deps/xbank/keeper/mock_balances.go)Script Updates (
scripts/benchmark.sh)BENCHMARK_CONFIGenv var to specify scenario filescripts/scenarios/EVMTransfer.jsonUsage
ERC20 benchmark with Giga Executor
GIGA_EXECUTOR=true BENCHMARK_CONFIG=scripts/scenarios/erc20.json ./scripts/benchmark.sh