<p>There's a difference between a software thread and a CPU thread. The number of threads that you are seeing is not the number of CPU threads that <code>bitcoind</code> is using. It is the number of software threads that it has created, which are different from CPU threads. You can't make the software create more software threads; that's not possible and not how the software is designed. You also can't make it use more CPU threads or whatever; that's not how computers work.</p>

CC BY-SA 3.0
2017-08-06T18:03:16.150Z
2017-08-06T18:03:16.150Z
Ava Chow
<p>More threads will not make your software run faster.</p>

<p>Threads are used in order to be able to do more things <em>concurrently</em>, but not necessarily faster overall. Assume your internet connection allows you to download at 1 MiB/s, and you want to download 5 files of 200 MiB each. No matter what, you need to download 1000 MiB, which will take 1000 seconds. But you could choose to either download them one by one, or all concurrently. If you download them concurrently, they'll individually progress more slowly, but overall still finish at the same time.</p>

<p>Your CPU has a number of cores, and can typically run one or two threads on each core (See <a href="https://en.wikipedia.org/wiki/Simultaneous_multithreading" rel="noreferrer">SMT</a>). For computationally intensive tasks, it is therefore advisable to have as many threads as you have cores, in order to keep all cores busy. However, more is not helpful in making things faster. In fact, because of increased need for communication between threads, doing so may even reduce throughput. Bitcoin Core will automatically detect how many cores your system has, and create that number of threads for transaction and block validation. If you want, you can change this number using the <code>par</code> setting in bitcoin.conf.</p>

<p>Most of the threads you see are however not computationally intensive, and are in fact idling most of the time. They're just there to deal with occasional things that need to happen in the background and not interfere with other operations. That includes threads for sending and receiving network messages, for cleaning up database files, for interacting with the user (reacting when you click somewhere with your mouse if you use Bitcoin-Qt for example), or for responding to RPC commands. For the last one, there is a setting to control how many RPC commands can be processed in parallel, namely <code>rpcthreads</code>. Due to locking, only 1 or a few RPC commands can actually execute in parallel, however.</p>

<p>So, you can change the number of threads for some tasks, but that's rarely needed, as the defaults usually get you close to the best performance. If you want to make block synchronization go faster, the best approach is increasing the database cache size (<code>dbcache</code>) or running on faster storage (SSD helps a lot).</p>

CC BY-SA 4.0
2020-11-07T01:25:29.670Z
Too many threads will overload your CPU caches causing more memory I/O which can actually slow down your system severely.
pisjatblin
CC BY-SA 3.0
2017-08-07T08:40:21.797Z
2017-08-07T18:49:43.473Z
2017-08-07T18:49:43.473Z
Pieter Wuille
<p>What field in config file or flag should I use to run <code>bitcoind -daemon</code> e.g. on 100 threads? Now I have 23 threads, but I want to increase this value.</p>

<pre><code>$ ps aux | grep bitcoind
pavlovd+  1258  2.3  1.7 2682460 916020 ?      Ssl  Aug05  43:22 bitcoind -daemon
$ ps -o nlwp 1258
NLWP
  23
</code></pre>

<bitcoind><bitcoin.conf><performance>
How to specify number of threads for bitcoind?
Sergey Potekhin
# How to specify number of threads for bitcoind?

(Asked by: username_0 on 2017-08-06)

What field in config file or flag should I use to run `bitcoind -daemon` e.g. on 100 threads? Now I have 23 threads, but I want to increase this value.

```
$ ps aux | grep bitcoind
pavlovd+  1258  2.3  1.7 2682460 916020 ?      Ssl  Aug05  43:22 bitcoind -daemon
$ ps -o nlwp 1258
NLWP
  23

```

**Tags:** bitcoind, bitcoin.conf, performance


---

## 2 answers

### Answer by username_2 on 2017-08-07. Score: 10 | Accepted answer

More threads will not make your software run faster.

Threads are used in order to be able to do more things *concurrently*, but not necessarily faster overall. Assume your internet connection allows you to download at 1 MiB/s, and you want to download 5 files of 200 MiB each. No matter what, you need to download 1000 MiB, which will take 1000 seconds. But you could choose to either download them one by one, or all concurrently. If you download them concurrently, they'll individually progress more slowly, but overall still finish at the same time.

Your CPU has a number of cores, and can typically run one or two threads on each core (See [SMT](https://en.wikipedia.org/wiki/Simultaneous_multithreading)). For computationally intensive tasks, it is therefore advisable to have as many threads as you have cores, in order to keep all cores busy. However, more is not helpful in making things faster. In fact, because of increased need for communication between threads, doing so may even reduce throughput. Bitcoin Core will automatically detect how many cores your system has, and create that number of threads for transaction and block validation. If you want, you can change this number using the `par` setting in bitcoin.conf.

Most of the threads you see are however not computationally intensive, and are in fact idling most of the time. They're just there to deal with occasional things that need to happen in the background and not interfere with other operations. That includes threads for sending and receiving network messages, for cleaning up database files, for interacting with the user (reacting when you click somewhere with your mouse if you use Bitcoin-Qt for example), or for responding to RPC commands. For the last one, there is a setting to control how many RPC commands can be processed in parallel, namely `rpcthreads`. Due to locking, only 1 or a few RPC commands can actually execute in parallel, however.

So, you can change the number of threads for some tasks, but that's rarely needed, as the defaults usually get you close to the best performance. If you want to make block synchronization go faster, the best approach is increasing the database cache size (`dbcache`) or running on faster storage (SSD helps a lot).

> **Comments:**
> **username_3**: Too many threads will overload your CPU caches causing more memory I/O which can actually slow down your system severely.  

---

### Answer by username_1 on 2017-08-06. Score: 3

There's a difference between a software thread and a CPU thread. The number of threads that you are seeing is not the number of CPU threads that `bitcoind` is using. It is the number of software threads that it has created, which are different from CPU threads. You can't make the software create more software threads; that's not possible and not how the software is designed. You also can't make it use more CPU threads or whatever; that's not how computers work.


---

