In #11281, commit ccd8ef6 the LOCK(cs_main)
scope was reduced for the wallet. This does the same for the rest API, which is a huge performance boost for rest_block
call when used from multiple threads.
I’m not 100% sure though if this is allowed here…
My test setup, on an Intel i7 with 6 cores (12 threads), locked to 3.2GHz:
- start a fully synced bitcoind, with this
bitcoin.conf
:0server=1 1rest=1 2rpcport=8332 3rpcthreads=12 4rpcworkqueue=64 5txindex=1 6dbcache=2000
- Wait until log message shows
loadblk thread exit
, so that bitcoind is idle. - Run ApacheBench: 10000 requests, 12 parallel threads, fetching block nr. 600000 in binary:
0ab -n 10000 -c 12 "http://127.0.0.1:8332/rest/block/00000000000000000007316856900e76b4f7a9139cfbfba89842c8d196cd5f91.bin"
Time per request (mean)
- 97.434 [ms] on master
- 20.431 [ms] this branch
So this can process 4.8 times as many requests, and saturates all my cores instead of keeping them partly idle waiting in the lock.