bench: add WalletBalanceManySpent for high-history wallet scenario #34360

pull w0xlt wants to merge 1 commits into bitcoin:master from w0xlt:wallet-balance-many-spent-bench-3 changing 2 files +192 −6
  1. w0xlt commented at 3:15 am on January 21, 2026: contributor

    This PR introduces a new benchmark that measures GetBalance() performance on wallets with extensive transaction history where the majority of outputs have already been spent.

    It was created to test #27865, which separates spent TXOs from spendable ones. This pattern mirrors real-world usage in high-activity wallets such as Lightning nodes, exchanges, hot wallets, and payment processors.

    Setup:

    • Creates 500 blocks × 100 coinbase outputs = 50,000 wallet TXOs
    • Matures all coinbases with COINBASE_MATURITY additional blocks
    • Spends 49,950 outputs in batched transactions (confirmed in blocks)
    • Consolidation outputs go to a burn script to avoid inflating wallet TXO count

    To keep the setup time reasonable, the benchmark uses the fast “fake block” approach, similar to wallet_create_tx.cpp.

  2. bench: add WalletBalanceManySpent for high-history wallet scenario
    Add a benchmark that measures `GetBalance()` performance on wallets with
    extensive transaction history where most outputs have been spent.
    
    Scenario: 50,000 TXOs with 49,950 spent and 50 unspent.
    
    This pattern is common in high-activity wallets (Lightning nodes, exchange
    hot wallets, payment processors) and is the target scenario for optimizations
    that separate spent TXOs from spendable ones.
    
    Setup:
    - Creates 500 blocks × 100 coinbase outputs = 50,000 wallet TXOs
    - Matures all coinbases with COINBASE_MATURITY additional blocks
    - Spends 49,950 outputs in batched transactions (confirmed in blocks)
    - Consolidation outputs go to a burn script to avoid inflating wallet TXO count
    
    Introduces `src/bench/wallet_bench_util.h` with utilities for wallet
    benchmarks (TipBlock, GetTip, GenerateFakeBlock).
    42805a1609
  3. DrahtBot added the label Tests on Jan 21, 2026
  4. DrahtBot commented at 3:15 am on January 21, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34360.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    No conflicts as of last run.

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • GenerateFakeBlock(params, test_setup->m_node, wallet, burn_script, 1) in src/bench/wallet_balance.cpp
    • GenerateFakeBlock(params, test_setup->m_node, wallet, burn_script, 1, 50 * COIN, block_txs) in src/bench/wallet_balance.cpp

    2026-01-21


w0xlt DrahtBot

Labels
Tests


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-22 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me