This guide helps you compare the performance of two different versions of Bitcoin Core during the initial block download (IBD) process. You will run two builds and share the results.
I am working on improving the performance of the first phase of Bitcoin Core, specifically the process of downloading and validating the blockchain on a fresh machine. I have proposed several modifications that, based on my own measurements, result in measurable speed improvements. However, to ensure broader acceptance, I need help reproducing these results by having others run similar tests.
This is a technical process (though not overly complex, in my opinion), requiring the source code to be compiled. The goal is to validate these improvements on multiple setups and environments, which will help accelerate their adoption.
- A GitHub account (to follow the discussion and results).
- A Linux-based system (e.g., Ubuntu/Debian).
- At least 1 TB of free space for blockchain data (temporary, can be deleted afterward).
Important: To keep the environment as consistent as possible, make sure no other applications or tasks are running on the machine during the experiment (can take several days).
Ideally, leave the machine idle for the duration of the test to avoid variability in the results.
Install the necessary packages (on Debian/Ubuntu). Only install packages from trusted sources!
apt update && apt upgrade -y
apt install -y bsdmainutils build-essential ccache clang cmake curl git htop libboost-chrono-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-test-dev libboost-thread-dev libdb++-dev libdb-dev libevent-dev libgmp-dev libminiupnpc-dev libsqlite3-dev libssl-dev libtool libzmq3-dev llvm pkg-config python3 python3-zmq python3-pip hyperfine
Download the Bitcoin Core source code and fetch the two commits you want to compare (I’m not telling you which is "before" and which is "after", the results should speak for themselves).
git clone https://github.com/bitcoin/bitcoin.git && cd bitcoin
git fetch origin 5acf12bafeb126f2190b3f401f95199e0eea90c9 caa68f79c11e5c444977ce8dee8a43020b7b3c5a
Create a directory for blockchain data. This directory will require around 1 TB of free space but can be deleted after the experiment.
mkdir -p BitcoinData BitcoinData-logs
Build the Bitcoin Core binaries using the following commands:
cmake -B build && cmake --build build -j4
Let’s get to testing! \:D/
Note that you will need at least 16 Gb memory - otherwise lower DBCACHE
to e.g. 500
.
Use hyperfine
for automation (or you can do it manually if you can keep track of the changes):
STOP_HEIGHT=880000; \
COMMITS=5acf12bafeb126f2190b3f401f95199e0eea90c9,0e9fb2ed330960c0e4cd36b077c64ac7d0f84240; \
DBCACHE=5000; \
hyperfine \
--runs 3 \
--parameter-list COMMIT $COMMITS \
--prepare "rm -rf BitcoinData/* build/ && 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/src/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=1 -printtoconsole=0 || true" \
--cleanup "cp /mnt/my_storage/BitcoinData/debug.log /mnt/my_storage/logs/debug-{COMMIT}-$(date +%s).log" \
"COMMIT={COMMIT} ./build/src/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE -printtoconsole=0"
You can also vary the number of runs (to test it in a different setting), e.g. --runs 2
or DBCACHE=10000
or -stopatheight=800000
or compile with CLang (cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
).
Post your results to bitcoin/bitcoin#31144 - making sure to include these details in your report:
- hyperfine output (or the gist of
BitcoinData-logs/*.json
) - CPU type.
- Whether you used an SSD or HDD.
- Internet connection speed.
- Any other relevant information about your environment.
Don't be too verbose, but share the important data (see previous replies for inspiration).
Thanks!
The working directory is in
bitcoin/
so use rather..BitcoinData/
and..BitcoinData-logs/
, with..
by pointing to the parent directory of the current directory.