Skip to content

[r3.4] db/state, txpool: benchmark fixes and bench flag improvements#20070

Merged
AskAlexSharov merged 1 commit intorelease/3.4from
anacrolix/backport/3.4/benchmark-fixes
Mar 23, 2026
Merged

[r3.4] db/state, txpool: benchmark fixes and bench flag improvements#20070
AskAlexSharov merged 1 commit intorelease/3.4from
anacrolix/backport/3.4/benchmark-fixes

Conversation

@anacrolix
Copy link
Copy Markdown
Contributor

Backport of #19971 to release/3.4.

Includes benchmark fixes and bench flag improvements for db/state and txpool.

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 AskAlexSharov merged commit 6cd164a into release/3.4 Mar 23, 2026
21 of 22 checks passed
@AskAlexSharov AskAlexSharov deleted the anacrolix/backport/3.4/benchmark-fixes branch March 23, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants