generatetoaddress 2-3x slower on v30 compared to v29 #33618

issue Christewart openend this issue on October 13, 2025
  1. Christewart commented at 11:16 pm on October 13, 2025: contributor

    Hardware

    0Darwin Chriss-MacBook-Pro.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:55 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6031 arm64
    

    v29

    0Bitcoin Core daemon version v29.0.0
    1Copyright (C) 2009-2025 The Bitcoin Core developers
    
    0$ time bitcoin-cli -regtest generatetoaddress 2000 $(bitcoin-cli -regtest getnewaddress)  
    10.01s user 0.01s system 0% cpu 1:56.41 total
    

    v30

    0Bitcoin Core daemon version v30.0.0
    1Copyright (C) 2009-2025 The Bitcoin Core developers
    
    0time bitcoin-cli -regtest generatetoaddress 2000 $(bitcoin-cli -regtest getnewaddress)  
    10.01s user 0.01s system 0% cpu 4:33.46 total
    
  2. mzumsande commented at 1:45 am on October 14, 2025: contributor
    I tried the same on Ubuntu / SSD and didn’t see a difference. Just to make sure: Did you start with an empty datadir and fresh wallet each run? (the longer the existing chain is, the slower generating more blocks will be on regtest because -checkblockindex is enabled by default there)
  3. l0rinc commented at 3:04 am on October 14, 2025: contributor

    I have also measured it a few different ways:

    Compiling from source and running it 3 times for v29.2 vs v30.30:

     0VERSIONS="29.2 30.0"; \
     1BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinRegtestData"; LOG_DIR="$BASE_DIR/logs"; \
     2git fetch origin --tags && \
     3for v in $VERSIONS; do \
     4  echo "Building v$v..."; \
     5  git checkout v$v && \
     6  rm -rf build-$v && \
     7  cmake -B build-$v -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo && \
     8  ninja -C build-$v bitcoind bitcoin-cli || exit 1; \
     9done && \
    10echo "generatetoaddress | $(hostname) | $(uname -m) | $(lscpu | grep 'Model name' | head -1 | cut -d: -f2 | xargs) | $(nproc) cores | $(free -h | awk '/^Mem:/{print $2}') RAM" && \
    11killall bitcoind 2>/dev/null || true; sleep 5; \
    12hyperfine \
    13  --runs 3 \
    14  --sort command \
    15  --export-json "$BASE_DIR/generatetoaddress-compiled-v$(echo $VERSIONS | tr ' ' '-').json" \
    16  --parameter-list VERSION ${VERSIONS// /,} \
    17  --prepare "killall bitcoind 2>/dev/null || true; sleep 5; rm -rf $DATA_DIR/*; \
    18             ./build-{VERSION}/bin/bitcoind -regtest -datadir=$DATA_DIR -daemon -printtoconsole=0; \
    19             ./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR -rpcwait createwallet test >/dev/null" \
    20  --conclude "cp $DATA_DIR/regtest/debug.log $LOG_DIR/debug-generatetoaddress-compiled-v{VERSION}-$(date +%s).log; \
    21              ./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR stop 2>/dev/null || true; \
    22              killall bitcoind 2>/dev/null || true; sleep 5" \
    23  "./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR generatetoaddress 2000 \$(./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR getnewaddress)"
    24
    25Benchmark 1: ./build-29.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(./build-29.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    26  Time (mean ± σ):     27.016 s ±  0.363 s    [User: 0.004 s, System: 0.002 s]
    27  Range (min … max):   26.726 s … 27.423 s    3 runs
    28
    29Benchmark 2: ./build-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(./build-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    30  Time (mean ± σ):     44.621 s ±  0.380 s    [User: 0.005 s, System: 0.001 s]
    31  Range (min … max):   44.191 s … 44.913 s    3 runs
    
    0Relative speed comparison
    1        1.00          ./build-29.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(./build-29.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    2        1.65 ±  0.03  ./build-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(./build-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    

    which indicated it’s indeed 65% slower.


    Tried it after that with the actual binaries (for a few more versions):

     0VERSIONS="27.2 28.2 29.1 30.0"; \
     1ARCH="x86_64"; \
     2BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinRegtestData"; LOG_DIR="$BASE_DIR/logs"; BIN_DIR="$BASE_DIR/bitcoin_bins"; \
     3mkdir -p "$BIN_DIR" "$LOG_DIR" "$DATA_DIR" && \
     4(echo "Preparing Bitcoin Core versions:"; \
     5for v in $VERSIONS; do \
     6  echo -n "v$v: "; \
     7  TAR="bitcoin-$v-$ARCH-linux-gnu.tar.gz"; \
     8  URL="https://bitcoincore.org/bin/bitcoin-core-$v/$TAR"; \
     9  if [ ! -f "$BIN_DIR/$TAR" ]; then echo -n "downloading... "; wget -q -P "$BIN_DIR" "$URL" || exit 1; fi; \
    10  if [ ! -d "$BIN_DIR/bitcoin-$v" ]; then echo -n "extracting... "; tar -xzf "$BIN_DIR/$TAR" -C "$BIN_DIR" || exit 1; fi; \
    11  echo "ready"; \
    12done; echo "") && \
    13killall bitcoind 2>/dev/null || true; sleep 5; \
    14echo "generatetoaddress | $(hostname) | $(uname -m) | $(lscpu | grep 'Model name' | head -1 | cut -d: -f2 | xargs) | $(nproc) cores | $(free -h | awk '/^Mem:/{print $2}') RAM" && \
    15hyperfine \
    16  --runs 3 \
    17  --sort command \
    18  --export-json "$BASE_DIR/generatetoaddress-v$(echo $VERSIONS | tr ' ' '-').json" \
    19  --parameter-list VERSION ${VERSIONS// /,} \
    20  --prepare "killall bitcoind 2>/dev/null || true; sleep 5; rm -rf $DATA_DIR/*; \
    21             $BIN_DIR/bitcoin-{VERSION}/bin/bitcoind -regtest -datadir=$DATA_DIR -daemon -printtoconsole=0; \
    22             $BIN_DIR/bitcoin-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR -rpcwait createwallet test >/dev/null" \
    23  --conclude "cp $DATA_DIR/regtest/debug.log $LOG_DIR/debug-generatetoaddress-v{VERSION}-$(date +%s).log; \
    24              $BIN_DIR/bitcoin-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR stop 2>/dev/null || true; \
    25              killall bitcoind 2>/dev/null || true; sleep 5" \
    26  "$BIN_DIR/bitcoin-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR generatetoaddress 2000 \$($BIN_DIR/bitcoin-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR getnewaddress)"
    27
    28Preparing Bitcoin Core versions:
    29v27.2: ready
    30v28.2: ready
    31v29.1: ready
    32v30.0: ready
    33
    34Benchmark 1: /mnt/my_storage/bitcoin_bins/bitcoin-27.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-27.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    35  Time (mean ± σ):     44.905 s ±  0.570 s    [User: 0.006 s, System: 0.006 s]
    36  Range (min … max):   44.247 s … 45.259 s    3 runs
    37
    38Benchmark 2: /mnt/my_storage/bitcoin_bins/bitcoin-28.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-28.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    39  Time (mean ± σ):     39.496 s ±  0.531 s    [User: 0.008 s, System: 0.007 s]
    40  Range (min … max):   39.087 s … 40.095 s    3 runs
    41
    42Benchmark 3: /mnt/my_storage/bitcoin_bins/bitcoin-29.1/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-29.1/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    43  Time (mean ± σ):     39.125 s ±  0.801 s    [User: 0.007 s, System: 0.005 s]
    44  Range (min … max):   38.621 s … 40.049 s    3 runs
    45
    46Benchmark 4: /mnt/my_storage/bitcoin_bins/bitcoin-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    47  Time (mean ± σ):     59.629 s ±  0.108 s    [User: 0.005 s, System: 0.007 s]
    48  Range (min … max):   59.524 s … 59.740 s    3 runs
    
    0Relative speed comparison
    1        1.15 ±  0.03  /mnt/my_storage/bitcoin_bins/bitcoin-27.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-27.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    2        1.01 ±  0.02  /mnt/my_storage/bitcoin_bins/bitcoin-28.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-28.2/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    3        1.00          /mnt/my_storage/bitcoin_bins/bitcoin-29.1/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-29.1/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    4        1.52 ±  0.03  /mnt/my_storage/bitcoin_bins/bitcoin-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData generatetoaddress 2000 $(/mnt/my_storage/bitcoin_bins/bitcoin-30.0/bin/bitcoin-cli -regtest -datadir=/mnt/my_storage/BitcoinRegtestData getnewaddress)
    

    i.e. v29 is faster than other versions and v30 is indeed 52% slower.


    Lastly, checked the same on my Mac, which also shows the same:

     0VERSIONS="29.2 30.0"; \
     1BASE_DIR="/Users/lorinc/IdeaProjects/bitcoin"; DATA_DIR="$BASE_DIR/BitcoinRegtestData"; \
     2mkdir -p "$DATA_DIR" && \
     3git fetch origin --tags && \
     4for v in $VERSIONS; do \
     5  echo "Building v$v..."; \
     6  git checkout v$v && \
     7  rm -rf build-$v && \
     8  cmake -B build-$v -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo && \
     9  ninja -C build-$v bitcoind bitcoin-cli || exit 1; \
    10done && \
    11killall bitcoind 2>/dev/null || true; sleep 10; \
    12hyperfine \
    13  --runs 3 \
    14  --sort command \
    15  --parameter-list VERSION ${VERSIONS// /,} \
    16  --prepare "killall bitcoind 2>/dev/null || true; sleep 10; rm -rf $DATA_DIR/*; \
    17             ./build-{VERSION}/bin/bitcoind -regtest -datadir=$DATA_DIR -daemon -printtoconsole=0; sleep 8; \
    18             ./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR -rpcwait createwallet test >/dev/null" \
    19  --conclude "./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR stop 2>/dev/null || true; \
    20              killall bitcoind 2>/dev/null || true; sleep 10" \
    21  "./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR generatetoaddress 2000 \$(./build-{VERSION}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR getnewaddress)"
    22
    23Benchmark 1: ./build-29.2/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-29.2/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
    24  Time (mean ± σ):      4.820 s ±  0.183 s    [User: 0.002 s, System: 0.000 s]
    25  Range (min … max):    4.665 s …  5.021 s    3 runs
    26
    27Benchmark 2: ./build-30.0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-30.0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
    28  Time (mean ± σ):      7.338 s ±  0.281 s    [User: 0.002 s, System: 0.000 s]
    29  Range (min … max):    7.145 s …  7.661 s    3 runs
    
    0Relative speed comparison
    1        1.00          ./build-29.2/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-29.2/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
    2        1.52 ±  0.08  ./build-30.0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-30.0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
    

    I will do a git bisect to see where it was introduced.

  4. l0rinc commented at 3:45 am on October 14, 2025: contributor

    It seems the commit that changed the behavior was https://github.com/bitcoin/bitcoin/commit/7bacabb204b6c34f9545f0b37e2c66296ad2c0de (cc: @achow101)

     0COMMITS="9a05b45da60d214cb1e5a50c3d2293b1defc9bb0,7bacabb204b6c34f9545f0b37e2c66296ad2c0de"; \
     1BASE_DIR="/Users/lorinc/IdeaProjects/bitcoin"; \
     2DATA_DIR="$BASE_DIR/BitcoinRegtestData"; \
     3mkdir -p "$DATA_DIR" && \
     4for c in ${COMMITS//,/ }; do \
     5  git checkout $c && rm -rf build-$c && cmake -B build-$c -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo && ninja -C build-$c bitcoind bitcoin-cli || exit 1; \
     6done && \
     7killall bitcoind 2>/dev/null || true; sleep 10; \
     8hyperfine \
     9  --runs 3 \
    10  --sort command \
    11  --parameter-list COMMIT $COMMITS \
    12  --prepare "killall bitcoind 2>/dev/null || true; sleep 10; rm -rf $DATA_DIR/*; \
    13             ./build-{COMMIT}/bin/bitcoind -regtest -datadir=$DATA_DIR -daemon -printtoconsole=0; sleep 8; \
    14             ./build-{COMMIT}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR -rpcwait createwallet test >/dev/null" \
    15  --conclude "./build-{COMMIT}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR stop 2>/dev/null || true; \
    16              killall bitcoind 2>/dev/null || true; sleep 10" \
    17  "./build-{COMMIT}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR generatetoaddress 2000 \$(./build-{COMMIT}/bin/bitcoin-cli -regtest -datadir=$DATA_DIR getnewaddress)"
    
     0Benchmark 1: ./build-9a05b45da60d214cb1e5a50c3d2293b1defc9bb0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-9a05b45da60d214cb1e5a50c3d2293b1defc9bb0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
     1  Time (mean ± σ):      4.690 s ±  0.224 s    [User: 0.002 s, System: 0.001 s]
     2  Range (min … max):    4.434 s …  4.848 s    3 runs
     3 
     4Benchmark 2: ./build-7bacabb204b6c34f9545f0b37e2c66296ad2c0de/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-7bacabb204b6c34f9545f0b37e2c66296ad2c0de/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
     5  Time (mean ± σ):      7.380 s ±  0.410 s    [User: 0.002 s, System: 0.001 s]
     6  Range (min … max):    7.072 s …  7.846 s    3 runs
     7 
     8Relative speed comparison
     9        1.00          ./build-9a05b45da60d214cb1e5a50c3d2293b1defc9bb0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-9a05b45da60d214cb1e5a50c3d2293b1defc9bb0/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
    10        1.57 ±  0.12  ./build-7bacabb204b6c34f9545f0b37e2c66296ad2c0de/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData generatetoaddress 2000 $(./build-7bacabb204b6c34f9545f0b37e2c66296ad2c0de/bin/bitcoin-cli -regtest -datadir=/Users/lorinc/IdeaProjects/bitcoin/BitcoinRegtestData getnewaddress)
    
  5. maflcko added the label Wallet on Oct 14, 2025
  6. maflcko added the label Resource usage on Oct 14, 2025
  7. maflcko added the label Tests on Oct 14, 2025
  8. achow101 commented at 1:29 pm on October 14, 2025: member

    It seems the commit that changed the behavior was 7bacabb

    That doesn’t make any sense. That commit doesn’t touch anything related to how addresses are generated.

  9. sipa commented at 1:32 pm on October 14, 2025: member
    @achow101 But it does touch things related to new blocks being created. Maybe the overhead of wallet writing the best block to the wallet more frequently has an impact here?
  10. furszy commented at 1:43 pm on October 14, 2025: member

    But it does touch things related to new blocks being created. Maybe the overhead of wallet writing the best block to the wallet more frequently has an impact here?

    we might want to revive #25297 in that case.

  11. achow101 commented at 2:23 pm on October 14, 2025: member

    Ah, sorry, misread the issue.

    This is expected behavior as a consequence of updating the wallet’s best block hash every time a block contains a transaction that belongs to the wallet. What’s happening is that we are writing to the wallet for each of these blocks now, whereas previously we were not. I think this behavior is preferred over the previous, even if it is slower.

  12. l0rinc commented at 2:44 pm on October 14, 2025: contributor

    I’ve generated a differential flamegraph comparing the commits before and after the regression: and

    Image Image Image Image

    rpc-report-9a05b45da6-1760449923.txt rpc-report-7bacabb204-1760450119.txt

     0COMMITS="9a05b45da60d214cb1e5a50c3d2293b1defc9bb0,7bacabb204b6c34f9545f0b37e2c66296ad2c0de"; \
     1CC=gcc; CXX=g++; \
     2BASE=/mnt/my_storage; FG=$BASE/FlameGraph; DATA_DIR="$BASE/BitcoinRegtestData"; LOG_DIR="$BASE/logs"; OUT=$BASE/flamegraphs/rpc-$(date +%s); \
     3mkdir -p "$OUT" "$LOG_DIR" "$DATA_DIR"; \
     4export CC CXX; \
     5flame_prepare(){ commit=$1; \
     6  killall -9 bitcoind 2>/dev/null; killall -9 perf 2>/dev/null; sleep 10; \
     7  git fetch -q origin "$commit" && git checkout -q "$commit" && \
     8  rm -rf build && \
     9  cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    10    -DCMAKE_C_FLAGS="-g3 -ggdb -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" \
    11    -DCMAKE_CXX_FLAGS="-g3 -ggdb -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" && \
    12  ninja -C build bitcoind bitcoin-cli -j2; }; \
    13flame_execute(){ tag=${1:0:10}; \
    14  echo 100000 | sudo tee /proc/sys/kernel/perf_event_max_sample_rate >/dev/null; \
    15  echo 0 | sudo tee /proc/sys/kernel/kptr_restrict >/dev/null; \
    16  echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid >/dev/null; \
    17  rm -rf "$DATA_DIR"/*; \
    18  build/bin/bitcoind -regtest -datadir="$DATA_DIR" -daemon -printtoconsole=0; sleep 8; \
    19  build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" -rpcwait createwallet test >/dev/null; \
    20  BITCOIND_PID=$(pgrep -f "bitcoind.*-regtest.*$DATA_DIR"); \
    21  perf record -F 99 -e cycles -g --call-graph fp -p $BITCOIND_PID -o "$OUT/rpc_$tag.data" -- sleep 60 & \
    22  PERF_PID=$!; \
    23  sleep 2; \
    24  build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" generatetoaddress 2000 $(build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" getnewaddress) >/dev/null; \
    25  wait $PERF_PID 2>/dev/null || true; \
    26  build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" stop 2>/dev/null; \
    27  sleep 5; \
    28  perf report --stdio -i "$OUT/rpc_$tag.data" > "$LOG_DIR/rpc-report-$tag-$(date +%s).txt" && \
    29  perf script -i "$OUT/rpc_$tag.data" 2>/dev/null | "$FG/stackcollapse-perf.pl" > "$OUT/rpc_$tag.folded" && \
    30  "$FG/flamegraph.pl" --title "RPC generatetoaddress $tag" "$OUT/rpc_$tag.folded" > "$OUT/rpc_$tag.svg"; }; \
    31flame_diff(){ first=${1:0:10}; second=${2:0:10}; \
    32  "$FG/difffolded.pl" -n "$OUT/rpc_${first}.folded" "$OUT/rpc_${second}.folded" > "$OUT/rpc_${first}-${second}.folded" && \
    33  "$FG/flamegraph.pl" --title "RPC generatetoaddress $first-$second" --colors hot --negate \
    34    "$OUT/rpc_${first}-${second}.folded" > "$OUT/rpc_${first}-${second}.svg"; }; \
    35A=${COMMITS%%,*}; B=${COMMITS##*,}; \
    36flame_prepare $A && flame_execute $A && \
    37flame_prepare $B && flame_execute $B && \
    38flame_diff $A $B && flame_diff $B $A; \
    39echo "RPC flamegraphs at: $OUT"
    
  13. Christewart commented at 3:39 pm on October 14, 2025: contributor
    As a side note, why was the generate command removed from the RPC interface? It seems like this RPC could be useful and avoid the performance hit of touching the wallet? I’m trying to dig through various PRs and issues and don’t see a straight forward answer, perhaps someone knows? #16000 #17700 #19133 #19455
  14. achow101 commented at 3:53 pm on October 14, 2025: member

    As a side note, why was the generate command removed from the RPC interface?

    Because of the separation between node things and wallet things. generate is testing only and there’s no good reason to have to add it to the node interface just for a convenience function.

    It seems like this RPChttps://github.com/bitcoin/bitcoin/issues/16000#issuecomment-491486488 and avoid the performance hit of touching the wallet?

    It would not make a difference. The behavior is not because of any repeated access to the wallet but rather because a bunch of blocks are being produced which are relevant to the wallet.

  15. Christewart commented at 3:59 pm on October 14, 2025: contributor

    As a side note, why was the generate command removed from the RPC interface?

    Because of the separation between node things and wallet things. generate is testing only and there’s no good reason to have to add it to the node interface just for a convenience function.

    I think providing helpful testing tools is a worthwhile goal. For instance it was deemed worthwhile to bring back the utility around in bitcoin-cli (#19133). Not everyone uses the entire bitcoin core stack for developing their infrastructure (i.e. bitcoin-cli), so why not expose these useful utilities to everyone? 🤷‍♂️ .

    The behavior is not because of any repeated access to the wallet but rather because a bunch of blocks are being produced which are relevant to the wallet.

    Yes, so have the generate RPC send funds a to an address that are not relevant to the wallet, which avoids the performance issue. I’ll be doing this to work around this performance regression, but it would be nice if bitcoin core just did this “out of the box”, IMO.

  16. achow101 commented at 4:02 pm on October 14, 2025: member

    Yes, so have the generate RPC send funds a to an address that are not relevant to the wallet

    Well the issues you mentioned are talking about the old generate which mined into a wallet.

    If you want to mine into a black hole, you can do that with generatetoaddress and a random address, or generatetodescriptor and raw(51).

  17. bitcoin deleted a comment on Oct 18, 2025

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: 2025-11-02 06:13 UTC

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