#35827 bench: add index benchmarks
https://github.com/bitcoin/bitcoin/pull/35827 · · +452/-0 in 7 files, 3 commits · labels: Tests
Goal
- Measure realistic block index sync and query performance without requiring a full initial block download
- Add benchmarks for indexes using blocks with multi-input and multi-output transactions
Adds shared utilities and benchmarks for index synchronization and lookups across txindex, txospenderindex, and blockfilterindex. It builds chains with realistic multi-transaction blocks to test write and lookup paths, and adds documentation on measuring I/O and memory usage with bench_bitcoin.
Problem: Index performance and memory optimizations currently lack granular benchmarks; the existing block filter benchmark only syncs coinbase transactions, and txindex has no benchmarks at all, forcing developers to rely on hours-long initial block download runs to test changes.
Category: Test infrastructure (#21 of 45)
P3 · test coverage
- P3 because index benchmarks only test coinbase-only blocks and fail to show scaling behavior
- Adds shared benchmark coverage for realistic transaction loads
Worthwhile addition to the benchmark suite. As stated in the description, there is currently 'no cheap way to tell whether a change actually improves what it set out to improve' for indexes without a full IBD, and existing benchmarks only cover coinbase transactions. It provides clear utility for evaluating index performance changes.
Membership: Adds new benchmark harnesses to src/bench/ for indexing subsystems.
Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1
Reviewability: Ready
- Ready for review
- All review feedback addressed and CI is clean
The author has addressed all initial review feedback from l0rinc with updated code and documentation.
Author status: Active; addressed reviewer comments and pushed fixes on 2026-09-06.
Resolved concerns:
- Locking inside the timed loop in index_sync_util.h could distort results (addressed by precomputing the expected tip outside the loop).
- Small benchmark sizes risk staying entirely in LevelDB write buffers or OS page cache without hitting disk (addressed by forcing chainstate flush and documenting -testdatadir).
Agreement: Strong
- Concept approval of the overall structure (l0rinc)
- All inline reviewer questions and feedback resolved by the author
Positive; Concept ACK from l0rinc with inline review concerns resolved by the author
l0rinc provided a Concept ACK and several constructive review comments, all of which were resolved in the author's follow-up commits.
- l0rinc gave Concept ACK on 2026-07-27
- arejula27 updated the implementation on 2026-09-06 to address locking, disk flushing, and documentation
Objections:
| Reviewer | Kind | Harm | Status | Blocking | Author replied | Quote |
|---|---|---|---|---|---|---|
| l0rinc | approach | Acquiring locks inside the benchmark timing loop could distort measurement results | resolved | no | yes | 2026-07-27: 'locking inside the measured block will likely distort the results' Settled: 2026-09-06: Expected tip is precomputed outside the loop with cs_main |
Support:
- l0rinc: Concept ACK, welcomed taking care of index benchmarks
Participants: l0rinc (support)
State derived from the lists: substantive support, no open objection (l0rinc) (model's own read: Positive)
Review verdicts (DrahtBot): 0
- Concept ACK: l0rinc
Files
414 lines under test/bench/ci.
- src/bench/index_sync_util.cpp +146/-0
- src/bench/index_sync_util.h +98/-0
- src/bench/index_txospender.cpp +68/-0
- src/bench/index_txindex.cpp +66/-0
- doc/benchmarking.md +38/-0
- src/bench/index_blockfilter.cpp +33/-0
- src/bench/CMakeLists.txt +3/-0
Card
This PR adds benchmarks in src/bench for txindex, txospenderindex, and blockfilterindex sync and lookup operations over chains with realistic multi-transaction blocks. It solves the lack of granular performance testing for index modifications, which previously required full initial block downloads to evaluate. It has received a Concept ACK from l0rinc, whose initial technical comments were addressed in a September 2026 push. It is ready for further review.