You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From a perspective of most workloads e.g. asking for blockchain data, bitcoind (and electrs) acts very much like database software, e.g. posgresql. Postgresql is an interesting case because it utilizes process-based model - meaning it will spawn not just a thread, but a whole process for every client connection - waaay heavier than just a thread.
It takes many threads to saturate modern IO device. Just an example from a yt video I had on hand benchamarking filesystems. Each bar is number of workers. And these are dedicated IO-generating workers, generating heavy load in a tight loop. So in this benchmark, it will take like 4 workers. Possibly one worker is even more threads. But an rpc thread in bitcoind by necessity will be spending lots of time reading things and writing stuff to a tcp connection, doing some checks, re-encodings and what not. To actually get a maximum IO performance there will need to be a lot of them. I'd say 64 per core.
On my mostly idle laptop at this very moment there are 2k threads running:
On a modern Linux a thread is just a stack, which due to CoW optimizations will really amount to 1 or 2 pages (4K page size) of physically used memory plus a tiny (1K?) amount to track it all in the kernel.
There's really not much to save on thread counts in a grand scheme of things.
Personally, I like to run as lots and lots of tests in parallel, especially any sort of integration and e2e tests, which tend to have lots of dead time - waiting for stuff (like disk and network IO - latency-bound things). The usual limit to this is the available memory. Additional benefit is also that it tends to expose problems more often, as all operations tend to have more ... timing jitter.
So I'm really surprised that the default in bitcoind is 4. That's too little even for an old generation raspberry pi.
For each thread a thread stack needs to be allocated. By default on Linux,
threads take up 8MiB for the thread stack on a 64-bit system, and 4MiB in a
32-bit system.
Only 8MiB of Virtual Memory is allocated, which doesn't really mean anything. Due to CoW mechanism, only the parts of stack that are being used will be allocated as Physical Memory which is the one that actually matters.
Expected behaviour
NA
Steps to reproduce
NA
Relevant log output
NA
How did you obtain Bitcoin Core
Other
What version of Bitcoin Core are you using?
na
Operating system and version
na
Machine specifications
Linux
The text was updated successfully, but these errors were encountered:
dpc
changed the title
Default rpcthreads value (40 is way too small
Default rpcthreads value (4) is too small
Feb 5, 2024
…queue
e56fc7c rpc: increase the defaults for -rpcthreads and -rpcworkqueue (Vasil Dimov)
Pull request description:
`rpcthreads` was introduced with a default of 4 in 2013 in 21eb5ad
`rpcworkqueue` was introduced with a default of 16 in 2015 in 40b556dResolves: #29386
---
Just bump the ancient default values. There is no perfect default that would fit everybody. This could lead to https://bikeshed.com/
ACKs for top commit:
achow101:
ACK e56fc7c
andrewtoth:
ACK e56fc7c
storopoli:
ACK e56fc7c
tdb3:
ACK e56fc7c
Tree-SHA512: ba3ea7392fda57950daa6b4c4d38ecdef9eebe5e786824d25f8b5cea03e760ffff7f77f3acd8eb6c6178b1e92b282e02cabb940ed7222eec7f73efdb819eef06
Is there an existing issue for this?
Current behaviour
I keep having to increase
rpcthreads
about everywhere I'm using bitcoind because without it it's not very robust/performant.Pasting verbatim my comment in bdk that just hit the same issue:
I just noticed the comment in the code:
Only 8MiB of Virtual Memory is allocated, which doesn't really mean anything. Due to CoW mechanism, only the parts of stack that are being used will be allocated as Physical Memory which is the one that actually matters.
Expected behaviour
NA
Steps to reproduce
NA
Relevant log output
NA
How did you obtain Bitcoin Core
Other
What version of Bitcoin Core are you using?
na
Operating system and version
na
Machine specifications
Linux
The text was updated successfully, but these errors were encountered: