Skip to content

Conversation

@l0rinc
Copy link
Collaborator

@l0rinc l0rinc commented Apr 16, 2025

@github-actions
Copy link

📊 Benchmark results for this run (14491957857) will be available at: https://bitcoin-dev-tools.github.io/benchcoin/results/pr-163/14491957857/index.html after the github pages "build and deployment" action has completed.
🚀 Speedups: mainnet-default-uninstrumented: 1.7%, mainnet-large-uninstrumented: 3.6%

@l0rinc
Copy link
Collaborator Author

l0rinc commented Apr 20, 2025

Rebased for better results.
Also ran a few rebases independently and interestingly it seems this former change isn't speeding up anything anymore - if it ever was...

COMMITS="eb48e1871bf3f08dd9baf3deff689108c0c99aed 0c50e4c5846417224c96965fda3f7a9264721707"; \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
STOP_HEIGHT=888888; DBCACHE=4500; \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
CC=gcc; CXX=g++; \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
(for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
hyperfine \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
  --sort 'command' \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  --runs 2 \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  --export-json "$BASE_DIR/rdx-${COMMITS// /-}-$STOP_HEIGHT-$DBCACHE-$CC.json" \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  --parameter-list COMMIT ${COMMITS// /,} \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
  --prepare "killall bitcoind; rm -f $DATA_DIR/debug.log; git checkout {COMMIT}; git clean -fxd; git reset --hard; \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && cmake --build build -j$(nproc) --target bitcoind && \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
    ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=5000 -printtoconsole=0; sleep 100" \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  "COMPILER=$CC ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

eb48e1871b revert bitcoin#16957
0c50e4c584 Add vertical lines for major protocol upgrades if this is a height-based plot

Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = eb48e1871bf3f08dd9baf3deff689108c0c99aed)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  Time (mean ± σ):     17156.967 s ±  9.928 s    [User: 22651.795 s, System: 955.218 s]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  Range (minmax):   17149.947 s17163.987 s    2 runs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = 0c50e4c5846417224c96965fda3f7a9264721707)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  Time (mean ± σ):     17855.921 s ± 34.436 s    [User: 23367.395 s, System: 966.584 s]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  Range (minmax):   17831.571 s17880.271 s    2 runs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Relative speed comparison                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
        1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = eb48e1871bf3f08dd9baf3deff689108c0c99aed)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
        1.04 ±  0.00  COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = 0c50e4c5846417224c96965fda3f7a9264721707)        

@github-actions
Copy link

📊 Benchmark results for this run (14563336819) will be available at: https://bitcoin-dev-tools.github.io/benchcoin/results/pr-163/14563336819/index.html after the github pages "build and deployment" action has completed.
🚀 Speedups: mainnet-default-uninstrumented: 1.7%, mainnet-large-uninstrumented: 3.6%

@l0rinc
Copy link
Collaborator Author

l0rinc commented Apr 22, 2025

on HDD:

COMMITS="d91a746815e4428c738f1a096a950292cbdb5469 3db4e71c9669a6692e699f037b9e5d2264cd9de8"; \
STOP_HEIGHT=888888; DBCACHE=4500; \
CC=gcc; CXX=g++; \
BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \
(for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \
hyperfine \
  --sort 'command' \
  --runs 2 \
  --export-json "$BASE_DIR/rdx-${COMMITS// /-}-$STOP_HEIGHT-$DBCACHE-$CC.json" \
  --parameter-list COMMIT ${COMMITS// /,} \
  --prepare "killall bitcoind; rm -f $DATA_DIR/debug.log; git checkout {COMMIT}; git clean -fxd; git reset --hard; \
    cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && cmake --build build -j$(nproc) --target bitcoind && \
    ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=5000 -printtoconsole=0; sleep 100" \
  --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \
  "COMPILER=$CC ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0"

d91a746 Merge bitcoin#32306: ci: Temporarily disable WalletMigration benchmark
3db4e71 Revert 67d9990

Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = d91a746815e4428c738f1a096a950292cbdb5469)
  Time (mean ± σ):     25734.584 s ± 295.031 s    [User: 23762.908 s, System: 947.410 s]
  Range (minmax):   25525.966 s25943.203 s    2 runs
 
Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = 3db4e71c9669a6692e699f037b9e5d2264cd9de8)
  Time (mean ± σ):     25041.004 s ± 90.525 s    [User: 23045.352 s, System: 945.514 s]
  Range (minmax):   24976.993 s25105.015 s    2 runs
 
Relative speed comparison
        1.03 ±  0.01  COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = d91a746815e4428c738f1a096a950292cbdb5469)
        1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = 3db4e71c9669a6692e699f037b9e5d2264cd9de8)

@l0rinc
Copy link
Collaborator Author

l0rinc commented Apr 23, 2025

DId an AssumeUTXO loading bench - 3-5% faster if we revert:

COMMITS="7a3afe6787bc36fd98684eac020f9abdbfae6f0a a74701b8a1f22867660d3a38bfa56242d9bb0f81"; \
CC=gcc; CXX=g++; \
BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/ShallowBitcoinData"; LOG_DIR="$BASE_DIR/logs"; UTXO_SNAPSHOT_PATH="$BASE_DIR/utxo-880000.dat"; \
(for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \
for DBCACHE in 450 4500 45000; do \
  hyperfine \
  --sort 'command' \
  --runs 3 \
  --export-json "$BASE_DIR/assumeutxo-${COMMITS// /-}-$DBCACHE-$CC.json" \
  --parameter-list COMMIT ${COMMITS// /,} \
  --prepare "killall bitcoind; rm -rf $DATA_DIR/chainstate $DATA_DIR/chainstate_snapshot $DATA_DIR/debug.log; git checkout {COMMIT}; git clean -fxd; git reset --hard; \
    cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && cmake --build build -j$(nproc) --target bitcoind --target bitcoin-cli && \
    ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=1 -printtoconsole=0; \
    ./build/bin/bitcoind -datadir=$DATA_DIR -daemon -blocksonly=1 -connect=0 -dbcache=$DBCACHE -printtoconsole=0; sleep 10" \
  --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-assumeutxo-{COMMIT}-dbcache-$DBCACHE-$(date +%s).log; build/bin/bitcoin-cli -datadir=$DATA_DIR stop; sleep 10; killall bitcoind; sleep 10;" \
  "COMPILER=$CC DBCACHE=$DBCACHE COMMIT={COMMIT} ./build/bin/bitcoin-cli -datadir=$DATA_DIR -rpcclienttimeout=0 loadtxoutset $UTXO_SNAPSHOT_PATH"; \
done

7a3afe6 Merge bitcoin#32281: bench: Fix WalletMigration benchmark
a74701b8a1 revert bitcoin#16957

Benchmark 1: COMPILER=gcc DBCACHE=450 COMMIT=7a3afe6787bc36fd98684eac020f9abdbfae6f0a ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
  Time (mean ± σ):     473.096 s ±  4.304 s    [User: 0.001 s, System: 0.002 s]
  Range (minmax):   468.230 s476.401 s    3 runs
 
Benchmark 2: COMPILER=gcc DBCACHE=450 COMMIT=a74701b8a1f22867660d3a38bfa56242d9bb0f81 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
  Time (mean ± σ):     458.987 s ±  5.851 s    [User: 0.001 s, System: 0.002 s]
  Range (minmax):   453.549 s465.179 s    3 runs
 
Relative speed comparison
        1.03 ±  0.02  COMPILER=gcc DBCACHE=450 COMMIT=7a3afe6787bc36fd98684eac020f9abdbfae6f0a ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
        1.00          COMPILER=gcc DBCACHE=450 COMMIT=a74701b8a1f22867660d3a38bfa56242d9bb0f81 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
Benchmark 1: COMPILER=gcc DBCACHE=4500 COMMIT=7a3afe6787bc36fd98684eac020f9abdbfae6f0a ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
  Time (mean ± σ):     495.739 s ±  4.520 s    [User: 0.002 s, System: 0.001 s]
  Range (minmax):   491.485 s500.485 s    3 runs
 
Benchmark 2: COMPILER=gcc DBCACHE=4500 COMMIT=a74701b8a1f22867660d3a38bfa56242d9bb0f81 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
  Time (mean ± σ):     473.514 s ±  4.761 s    [User: 0.002 s, System: 0.001 s]
  Range (minmax):   468.169 s477.299 s    3 runs
 
Relative speed comparison
        1.05 ±  0.01  COMPILER=gcc DBCACHE=4500 COMMIT=7a3afe6787bc36fd98684eac020f9abdbfae6f0a ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
        1.00          COMPILER=gcc DBCACHE=4500 COMMIT=a74701b8a1f22867660d3a38bfa56242d9bb0f81 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
Benchmark 1: COMPILER=gcc DBCACHE=45000 COMMIT=7a3afe6787bc36fd98684eac020f9abdbfae6f0a ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
  Time (mean ± σ):     471.687 s ±  0.725 s    [User: 0.001 s, System: 0.001 s]
  Range (minmax):   470.914 s472.352 s    3 runs
 
Benchmark 2: COMPILER=gcc DBCACHE=45000 COMMIT=a74701b8a1f22867660d3a38bfa56242d9bb0f81 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
  Time (mean ± σ):     455.890 s ±  0.593 s    [User: 0.001 s, System: 0.001 s]
  Range (minmax):   455.297 s456.483 s    3 runs
 
Relative speed comparison
        1.03 ±  0.00  COMPILER=gcc DBCACHE=45000 COMMIT=7a3afe6787bc36fd98684eac020f9abdbfae6f0a ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
        1.00          COMPILER=gcc DBCACHE=45000 COMMIT=a74701b8a1f22867660d3a38bfa56242d9bb0f81 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat

Let's see if this is still better
@l0rinc
Copy link
Collaborator Author

l0rinc commented Apr 23, 2025

Memory usage seems to increase a bit, which is likely because DynamicUsage(const std::unordered_map doesn't account for the hash cash - though using CCoinsMap does:

Most implementations have an overhead of 1 or 2 pointers, so nodes can be connected in a linked list, and in some cases the hash value is stored as well.

    MB
744.1^#                                                                       
     |#::::::::@::::::::::::    ::::::: :::  :::                              
     |#: :: :: @: :: ::: ::   : : ::::  : :  : :                              
     |#: :: :: @: :: ::: ::  :: : ::::  : :  : :                              
     |#: :: :: @: :: ::: ::  :: : :::: @: :  : :                              
     |#: :: :: @: :: ::: :: @:: : :::: @: :  : :                              
     |#: :: :: @: :: ::: :: @:: : :::: @: :  : :                              
     |#: :: :: @: :: ::: :: @:::: :::: @: :  : :                              
     |#: :: :: @: :: ::: :: @:::: :::: @: :  : :                              
     |#: :: :: @: :: ::: :: @:::: :::: @: :  : :::                            
     |#: :: :: @: :: ::: :: @:::: :::: @: :  : ::                             
     |#: :: :: @: :: ::: :: @:::: :::: @: :::: ::                             
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : ::                             
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : :: ::::@@:::::::@@:::@::::@::::
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : :: : : @ : : :: @ : :@::::@::::
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : :: : : @ : : :: @ : :@::::@::::
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : :: : : @ : : :: @ : :@::::@::::
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : :: : : @ : : :: @ : :@::::@::::
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : :: : : @ : : :: @ : :@::::@::::
     |#: :: :: @: :: ::: :: @:::: :::: @: :: : :: : : @ : : :: @ : :@::::@::::
   0 +----------------------------------------------------------------------->h
     0                                                                   1.807

vs

    MB
766.5^                                   ::                                   
     | #:::  ::     ::: :::: :::@::::   :: :::::::                            
     | #:::::::: :::::: :::: :::@::::  ::: :::: ::                            
     | #::::::::::::::: :::: :::@::::  ::: :::: ::                            
     | #::::::::::::::: :::: :::@::::  ::: :::: ::                            
     | #:::::::::::::::@:::: :::@::::  ::: :::: ::                            
     | #:::::::::::::::@:::: :::@::::  ::: :::: ::                            
     | #:::::::::::::::@:::: :::@::::  ::: :::: ::                            
     | #:::::::::::::::@::::::::@::::::::: :::: ::                            
     | #:::::::::::::::@::::::::@::::: ::: :::: ::                            
     | #:::::::::::::::@::::::::@::::: ::: :::: ::                            
     | #:::::::::::::::@::::::::@::::: ::: :::: ::                            
     | #:::::::::::::::@::::::::@::::: ::: :::: ::                            
     | #:::::::::::::::@::::::::@::::: ::: :::: ::                            
     | #:::::::::::::::@::::::::@::::: ::: :::: :::::::@::::@::::@::::@::::@::
     | #:::::::::::::::@::::::::@::::: ::: :::: ::: :::@::::@::::@::::@::::@::
     | #:::::::::::::::@::::::::@::::: ::: :::: ::: :::@::::@::::@::::@::::@::
     | #:::::::::::::::@::::::::@::::: ::: :::: ::: :::@::::@::::@::::@::::@::
     | #:::::::::::::::@::::::::@::::: ::: :::: ::: :::@::::@::::@::::@::::@::
     | #:::::::::::::::@::::::::@::::: ::: :::: ::: :::@::::@::::@::::@::::@::
   0 +----------------------------------------------------------------------->h
     0                                                                   1.739

If we fix the DynamicUsage method, it runs just as fast as master while using less peak memory:

    MB
709.7^#                                                                       
     |# ::::    ::   :: ::::@    @:::  :::::::                                
     |#::::::::@::::::  : ::@:: :@::::::: : ::@@::                            
     |#::::::::@::::::  : ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@:: :@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ ::                            
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ :::::@::@::::@:::::@::::@::::@
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ :::: @::@::::@:::::@::::@::::@
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ :::: @::@::::@:::::@::::@::::@
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ :::: @::@::::@:::::@::::@::::@
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ :::: @::@::::@:::::@::::@::::@
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ :::: @::@::::@:::::@::::@::::@
     |#::::::::@:::::: :: ::@::::@::::::: : ::@ :::: @::@::::@:::::@::::@::::@
   0 +----------------------------------------------------------------------->h
     0                                                                   1.814

Note that this was already included in `using CCoinsMap`:
> Most implementations have an overhead of 1 or 2 pointers, so nodes can be connected in a linked list, and in some cases the hash value is stored as well.
@github-actions
Copy link

📊 Benchmark results for this run (14613807216) will be available at: https://bitcoin-dev-tools.github.io/benchcoin/results/pr-163/14613807216/index.html after the github pages "build and deployment" action has completed.
🚀 Speedups: mainnet-default-uninstrumented: 0.6%, mainnet-large-uninstrumented: 1.6%

@github-actions
Copy link

📊 Benchmark results for this run (14617315459) will be available at: https://bitcoin-dev-tools.github.io/benchcoin/results/pr-163/14617315459/index.html after the github pages "build and deployment" action has completed.
🚀 Speedups: mainnet-default-uninstrumented: -1.2%, mainnet-large-uninstrumented: 2.5%

@l0rinc
Copy link
Collaborator Author

l0rinc commented Apr 24, 2025

Ran a AssumeUTXO bench with different dbcache sizes - with a lot lower memory (because of the last commit) the speed is still better. For very low memory it's slower (but uses a lot lower memory). We could fix that by increasing the default memory.

COMMITS="0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 6df3234893cf2ef6c42100f6358c1208a2952be9 e9800f880c869c346ad4141977d9132d51d7080e"; \                                 
CC=gcc; CXX=g++; \                                                                                                                                                                        
BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/ShallowBitcoinData"; LOG_DIR="$BASE_DIR/logs"; UTXO_SNAPSHOT_PATH="$BASE_DIR/utxo-880000.dat"; \                                                                    
(for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \                                                                              
for DBCACHE in 450 4500 45000; do \                                                                                                                                                                                                 
  hyperfine \                                                                                                                                                                                         
  --sort 'command' \                                                                                              
  --runs 3 \                                                                                                                                                                                                        
  --export-json "$BASE_DIR/assumeutxo-${COMMITS// /-}-$DBCACHE-$CC.json" \                                                                                                                                                          
  --parameter-list COMMIT ${COMMITS// /,} \                                                  
  --prepare "killall bitcoind; rm -rf $DATA_DIR/chainstate $DATA_DIR/chainstate_snapshot $DATA_DIR/debug.log; git checkout {COMMIT}; git clean -fxd; git reset --hard; \                  
    cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && cmake --build build -j$(nproc) --target bitcoind --target bitcoin-cli && \                                                       
    ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=1 -printtoconsole=0; \                                                                                                                                    
    ./build/bin/bitcoind -datadir=$DATA_DIR -daemon -blocksonly=1 -connect=0 -dbcache=$DBCACHE -printtoconsole=0; sleep 10" \                                                                                                       
  --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-assumeutxo-{COMMIT}-dbcache-$DBCACHE-$(date +%s).log; build/bin/bitcoin-cli -datadir=$DATA_DIR stop; sleep 10; killall bitcoind; sleep 10;" \                                    
  "COMPILER=$CC DBCACHE=$DBCACHE COMMIT={COMMIT} ./build/bin/bitcoin-cli -datadir=$DATA_DIR -rpcclienttimeout=0 loadtxoutset $UTXO_SNAPSHOT_PATH"; \                                                                                
done

0f3964f Add vertical lines for major protocol upgrades if this is a height-based plot
6df3234 revert bitcoin#16957
e9800f8 Include hash cash in DynamicUsage

Benchmark 1: COMPILER=gcc DBCACHE=450 COMMIT=0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat 
  Time (mean ± σ):     480.490 s ± 11.381 s    [User: 0.000 s, System: 0.002 s]              
  Range (minmax):   469.866 s492.500 s    3 runs                                                                                                                                                              
                                                                                                                                                                                          
Benchmark 2: COMPILER=gcc DBCACHE=450 COMMIT=6df3234893cf2ef6c42100f6358c1208a2952be9 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat 
  Time (mean ± σ):     463.958 s ±  5.475 s    [User: 0.001 s, System: 0.002 s]                                                                                                           
  Range (minmax):   458.823 s469.720 s    3 runs                                       
                                                                                                                                                                                                      
Benchmark 3: COMPILER=gcc DBCACHE=450 COMMIT=e9800f880c869c346ad4141977d9132d51d7080e ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                               
  Time (mean ± σ):     516.842 s ±  6.195 s    [User: 0.000 s, System: 0.002 s]                                                                                                                                                     
  Range (minmax):   510.361 s522.704 s    3 runs                                                                                                                                                                              
                                                                                                                                                                                                                                    
Relative speed comparison                                                                                                                                                                                                           
        1.04 ±  0.03  COMPILER=gcc DBCACHE=450 COMMIT=0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                      
        1.00          COMPILER=gcc DBCACHE=450 COMMIT=6df3234893cf2ef6c42100f6358c1208a2952be9 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                      
        1.11 ±  0.02  COMPILER=gcc DBCACHE=450 COMMIT=e9800f880c869c346ad4141977d9132d51d7080e ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
Benchmark 1: COMPILER=gcc DBCACHE=4500 COMMIT=0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat 
  Time (mean ± σ):     487.646 s ±  3.368 s    [User: 0.001 s, System: 0.001 s]                                                                                                                       
  Range (minmax):   484.786 s491.358 s    3 runs                                                            
                                                                                                   
Benchmark 2: COMPILER=gcc DBCACHE=4500 COMMIT=6df3234893cf2ef6c42100f6358c1208a2952be9 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat 
  Time (mean ± σ):     475.006 s ±  3.147 s    [User: 0.001 s, System: 0.002 s]                                   
  Range (minmax):   472.758 s478.602 s    3 runs                                                                                                                                                              
                                                     
Benchmark 3: COMPILER=gcc DBCACHE=4500 COMMIT=e9800f880c869c346ad4141977d9132d51d7080e ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                              
  Time (mean ± σ):     474.334 s ±  0.691 s    [User: 0.002 s, System: 0.001 s]                                                                                                                                                     
  Range (minmax):   473.679 s475.056 s    3 runs                                                    
                                                                                                                                                                                                                                    
Relative speed comparison                                
        1.03 ±  0.01  COMPILER=gcc DBCACHE=4500 COMMIT=0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
        1.00 ±  0.01  COMPILER=gcc DBCACHE=4500 COMMIT=6df3234893cf2ef6c42100f6358c1208a2952be9 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                     
        1.00          COMPILER=gcc DBCACHE=4500 COMMIT=e9800f880c869c346ad4141977d9132d51d7080e ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
Benchmark 1: COMPILER=gcc DBCACHE=45000 COMMIT=0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                             
  Time (mean ± σ):     475.820 s ±  9.651 s    [User: 0.001 s, System: 0.002 s]                                                                     
  Range (minmax):   469.527 s486.932 s    3 runs                                                                                              
                                                                          
Benchmark 2: COMPILER=gcc DBCACHE=45000 COMMIT=6df3234893cf2ef6c42100f6358c1208a2952be9 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                             
  Time (mean ± σ):     456.508 s ±  0.869 s    [User: 0.001 s, System: 0.001 s]                                                                     
  Range (minmax):   455.860 s457.496 s    3 runs                                                                                              
                                                                          
Benchmark 3: COMPILER=gcc DBCACHE=45000 COMMIT=e9800f880c869c346ad4141977d9132d51d7080e ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat                                                                             
  Time (mean ± σ):     456.342 s ±  0.469 s    [User: 0.001 s, System: 0.001 s]                                                                     
  Range (minmax):   455.806 s456.675 s    3 runs                                                                                              
                                                                          
Relative speed comparison                                                 
        1.04 ±  0.02  COMPILER=gcc DBCACHE=45000 COMMIT=0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
        1.00 ±  0.00  COMPILER=gcc DBCACHE=45000 COMMIT=6df3234893cf2ef6c42100f6358c1208a2952be9 ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat
        1.00          COMPILER=gcc DBCACHE=45000 COMMIT=e9800f880c869c346ad4141977d9132d51d7080e ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/ShallowBitcoinData -rpcclienttimeout=0 loadtxoutset /mnt/my_storage/utxo-880000.dat

@l0rinc
Copy link
Collaborator Author

l0rinc commented Apr 25, 2025

Turns out even reindex-chainstate with -dbcache=450 is faster (by 1%) AND consumes a less peak memory (by 4.9%):

COMMITS="0f3964f5b3d4e38355d4db4040b8e059fb8e75e8 e9800f880c869c346ad4141977d9132d51d7080e"; \                                                          
STOP_HEIGHT=888888; DBCACHE=450; \                                                                                                                                                                                  
CC=gcc; CXX=g++; \                                                                                                                                                                                                  
BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \                                                                                                                           
(for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \                                                                                                        
hyperfine \                                                                                               
  --sort 'command' \                                                                                      
  --runs 2 \                                                                                              
  --export-json "$BASE_DIR/rdx-${COMMITS// /-}-$STOP_HEIGHT-$DBCACHE-$CC.json" \                                                                                                                                    
  --parameter-list COMMIT ${COMMITS// /,} \                                                               
  --prepare "killall bitcoind; rm -f $DATA_DIR/debug.log; git checkout {COMMIT}; git clean -fxd; git reset --hard; \                                                                                                
    cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && cmake --build build -j$(nproc) --target bitcoind && \                                                                                          
    ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=5000 -printtoconsole=0; sleep 100" \                                                                                                
  --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \                                                                                                                                      
  "COMPILER=$CC ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0"

0f3964f Add vertical lines for major protocol upgrades if this is a height-based plot
e9800f8 Include hash cash in DynamicUsage

Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=450 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = 0f3964f5b3d4e38355d4db4040b8e059fb8e75e8)                                   
  Time (mean ± σ):     21642.550 s ± 38.787 s    [User: 36420.107 s, System: 2727.113 s]                                                                                                                            
  Range (minmax):   21615.124 s21669.976 s    2 runs                                                
                                                                                                          
Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=450 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = e9800f880c869c346ad4141977d9132d51d7080e)                                                        
  Time (mean ± σ):     21441.898 s ± 46.203 s    [User: 36259.157 s, System: 2802.353 s]                  
  Range (minmax):   21409.227 s21474.568 s    2 runs                                                
                                                     
Relative speed comparison                            
        1.01 ±  0.00  COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=450 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = 0f3964f5b3d4e38355d4db4040b8e059fb8e75e8)                          
        1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=450 -blocksonly -reindex-chainstate -connect=0 -printtoconsole=0 (COMMIT = e9800f880c869c346ad4141977d9132d51d7080e)                          

@l0rinc
Copy link
Collaborator Author

l0rinc commented May 1, 2025

Latest measurement:

COMMITS="c5e44a043563dbe5439d1cd8e623467936db1187 8ce5f597b7343dc2f06b41687ec25ffad3811e00 fd5852cd3d132e67184fee8b7ded06e7daaef1c1"; \
STOP_HEIGHT=888888; DBCACHE=4500; \
CC=gcc; CXX=g++; \
BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \
(echo ""; for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done; echo "") && \
hyperfine \
  --sort 'command' \
  --runs 2 \
  --export-json "$BASE_DIR/rdx-${COMMITS// /-}-$STOP_HEIGHT-$DBCACHE-$CC.json" \
  --parameter-list COMMIT ${COMMITS// /,} \
  --prepare "killall bitcoind; rm -f $DATA_DIR/debug.log; git checkout {COMMIT}; git clean -fxd; git reset --hard; \
    cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && cmake --build build -j$(nproc) --target bitcoind && \
    ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=5000 -printtoconsole=0; sleep 100" \
  --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \
  "COMPILER=$CC ./build/bin/bitcoind -datadir=$DATA_DIR -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE"

c5e44a0 Merge bitcoin#32369: test: Use the correct node for doubled keypath test
8ce5f59 revert bitcoin#16957
fd5852c Include hash cash in DynamicUsage

Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 -stopatheight=888888 -dbcache=4500 (COMMIT = c5e44a043563dbe5439d1cd8e623467936db1187)
  Time (mean ± σ):     26571.096 s ± 65.731 s    [User: 23751.494 s, System: 955.961 s]
  Range (minmax):   26524.618 s26617.575 s    2 runs
 
Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 -stopatheight=888888 -dbcache=4500 (COMMIT = 8ce5f597b7343dc2f06b41687ec25ffad3811e00)
  Time (mean ± σ):     26059.562 s ± 73.187 s    [User: 23145.020 s, System: 955.581 s]
  Range (minmax):   26007.811 s26111.313 s    2 runs
 
Benchmark 3: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 -stopatheight=888888 -dbcache=4500 (COMMIT = fd5852cd3d132e67184fee8b7ded06e7daaef1c1)
  Time (mean ± σ):     26343.847 s ±  2.230 s    [User: 23396.385 s, System: 990.685 s]
  Range (minmax):   26342.270 s26345.424 s    2 runs
Relative speed comparison
        1.02 ±  0.00  COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 -stopatheight=888888 -dbcache=4500 (COMMIT = c5e44a043563dbe5439d1cd8e623467936db1187)
        1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 -stopatheight=888888 -dbcache=4500 (COMMIT = 8ce5f597b7343dc2f06b41687ec25ffad3811e00)
        1.01 ±  0.00  COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 -stopatheight=888888 -dbcache=4500 (COMMIT = fd5852cd3d132e67184fee8b7ded06e7daaef1c1)

@l0rinc
Copy link
Collaborator Author

l0rinc commented May 5, 2025

c5e44a0 vs 8ce5f59
cache_vs_time

@l0rinc
Copy link
Collaborator Author

l0rinc commented May 5, 2025

c5e44a0 vs fd5852c

cache_coins_vs_time

@l0rinc
Copy link
Collaborator Author

l0rinc commented May 5, 2025

coins_resource_is_used fails with some weird reason

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.

1 participant