[r3.4] db/state, txpool: benchmark fixes and bench flag improvements#20070
Merged
AskAlexSharov merged 1 commit intorelease/3.4from Mar 23, 2026
Merged
Conversation
Two independent benchmark fixes. **`BenchmarkProcessRemoteTxns` panic**: mixed `b.Loop()` (Go 1.24+ API) for the benchmark loop with `b.N`-based pre-allocation for test data. On the first `runN` call `b.N=1`, so only 1 transaction is pre-created, then `b.Loop()` tries a second iteration and panics with `slice bounds out of range [:2] with capacity 1`. Fixed by switching back to `for i := 0; i < b.N; i++`. **`bench.loopv` split**: the shared flag was used in two benchmarks with semantically different meanings — CPU loop iterations in one, milliseconds of sleep in the other. These don't line up in magnitude: a value that makes sense for one (e.g. `100000` CPU iterations ≈ fast) is catastrophic for the other (`100000 ms = 100 seconds` sleep per iteration). With the default of `100000`, `BenchmarkDb_BeginFiles_Throughput` slept 100 seconds per iteration, completing only 1 iteration in a 112-second run. Split into `bench.cpu-iters` (default 1000) and `bench.sleep-ms` (default 5ms, matching the hardcoded value in `BenchmarkDb_BeginFiles_Throughput_IO`). --------- Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
AskAlexSharov
approved these changes
Mar 23, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #19971 to release/3.4.
Includes benchmark fixes and bench flag improvements for
db/stateandtxpool.