From 0ca4295f2e5f4443a1f8b3bae7cba0f6c054276f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Sun, 25 Jan 2026 15:00:49 +0100 Subject: [PATCH] bench: add on-disk `HaveInputs` benchmark `CCoinsViewCache::HaveInputs()` is used by `Consensus::CheckTxInputs()` and currently exercises the `HaveCoin()` path in the UTXO cache. Performance could be affected due to `Coin` copying and different cache warming behavior. Add a benchmark to track `HaveInputs()` throughput before and after the `HaveCoin()` changes in this series to make sure the performance is retained. The benchmark populates an on-disk `CCoinsViewDB` with dummy unspent coins for all block inputs and then calls `HaveInputs()` for each non-coinbase transaction using a fresh `CCoinsViewCache` (to avoid cross-iteration caching). It calls `HaveInputs()` twice to exercise the cache-hit path as well. Benchmark baseline: | ns/tx | tx/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 1,004.58 | 995,437.07 | 0.7% | 1.10 | `HaveInputsOnDisk` --- src/bench/CMakeLists.txt | 1 + src/bench/coins_haveinputs.cpp | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/bench/coins_haveinputs.cpp diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt index 50b29a14667..c441bfc7eb8 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable(bench_bitcoin checkblockindex.cpp checkqueue.cpp cluster_linearize.cpp + coins_haveinputs.cpp connectblock.cpp crypto_hash.cpp descriptors.cpp diff --git a/src/bench/coins_haveinputs.cpp b/src/bench/coins_haveinputs.cpp new file mode 100644 index 00000000000..ab6a4b0d747 --- /dev/null +++ b/src/bench/coins_haveinputs.cpp @@ -0,0 +1,48 @@ +// Copyright (c) 2026-present The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://opensource.org/license/mit/. + +#include +#include +#include +#include +#include +#include