How many threads should I run on this machine?

My lscpu says there are 96 cores. Are those physical cores? What is the maximum and optimal thread that I can run on this machine?

https://stackoverflow.com/a/10670440/610569 show that I can run over 20 threads per core. Is that okay? Is that optimal?

alvas@server:~$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                96
On-line CPU(s) list:   0-95
Thread(s) per core:    2
Core(s) per socket:    12
Socket(s):             4
NUMA node(s):          4
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 62
Model name:            Intel(R) Xeon(R) CPU E5-4657L v2 @ 2.40GHz
Stepping:              4
CPU MHz:               2700.000
CPU max MHz:           2900.0000
CPU min MHz:           1200.0000
BogoMIPS:              4801.91
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              30720K
NUMA node0 CPU(s):     0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92
NUMA node1 CPU(s):     1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93
NUMA node2 CPU(s):     2,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,66,70,74,78,82,86,90,94
NUMA node3 CPU(s):     3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63,67,71,75,79,83,87,91,95

Pardon my noobiness in cores/threads.

4 Answers 4


This is what you want to know

Thread(s) per core:    2
Core(s) per socket:    12
Socket(s):             4

You have 4 CPU sockets, each CPU can have, up to, 12 cores and each core can have two threads.

Your max thread count is, 4 CPU x 12 cores x 2 threads per core, so 12 x 4 x 2 is 96. Therefore the max thread count is 96 and max core count is 48.

What is better ?

That depends on what you want to do, more threads means less frequency (ie a 3ghz becomes split in two) but better multi-tasking (more threads) and using full cores (no hyper-threading) is better for high CPU usage tasks (ie games).

Hope this helps you.

  • 4
    "more threads means less frequency ", this statement is very wrong. Even with hyperthreading, a single lone process can make complete use of the processor. Hyperthreading can make use of instruction pipelines and registers that would otherwise be idle to do some executions from different processes/threads in parallel, increasing maximum throughput of a processor in certain cases. Performance gains are very application/configuration. After the P4 there are no documented performance penalties with HT enabled (the P4 gen cores had some issues in certain cases)
    – NGRhodes
    Commented Sep 2, 2015 at 18:44
  • 2
    I don't see this statement as very wrong. If you run two processes on a single core, less frequency is available for each process, when compared to running each process on its own core. It is a very basic and simplistic statement, but the OP never requested any detail about hyper-threading or how it works. Though you are correct, hyper-threading has come a long way and with 48 cores i am sure they would not want to turn it off.
    – Mark Kirby
    Commented Sep 2, 2015 at 19:05
  • 2
    @NGRhodes: Intel HT is fine-grained enough to overlap out-of-order execution between two threads. This is basically the whole point of HT, to expose more instruction-level parallelism to the out-of-order core. (i.e. keeping those execution units fed even while one thread is recovering from a branch mispredict or waiting on a cache miss.) Front-end issue bandwidth is split 50/50 (except when one thread is stalled), so depending on what kind of bottleneck your code runs into, HT might give you nearly double throughput, or nearly no extra throughput. (Like 15% for x264 video encoding.) Commented Nov 9, 2017 at 4:57
  • 1
    See agner.org/optimize for the microarchitectural details. Commented Nov 9, 2017 at 4:58

Your machine:

4 Sockets x 12 Cores/socket x 2 Threads/core, that's 96 threads and 48 cores

Ideally, no I/O, synchronization, etc., and there's nothing else running, use 48 threads of task.

Realistically, use about 95 threads may be better to exploit the max of your machine.


a core waits for data or I/O sometimes, so thread 2 could run while thread 1 not running.

Finally, you should test to get the best number based on your specific tasks.


Each cpu core thread ( hardware-based thread ) - one of your 96 cores efficiently can handle 16 threads ( software-based thread f.e. C++ thread.h ) in most cases in my theoretical opinion.

  • 2
    where did you get "efficiently can handle 16 threads" ? The output says "Thread(s) per core: 2" Commented Sep 4, 2019 at 15:52

You will find how many threads you can run on your machine by running htop or ps command that returns number of process on your machine.

You can use man page about 'ps' command.

man ps

If you want to calculate number of all users process, you can use one of these commands:

  1. ps -aux| wc -l
  2. ps -eLf | wc -l

Calculating number of an user process:

  1. ps --User root | wc -l

Also, you can use "htop" [Reference]:

Installing on Ubuntu or Debian:

sudo apt-get install htop

Installing on Redhat or CentOS:

yum install htop
dnf install htop      [On Fedora 22+ releases]

If you want to compile htop from source code, you will find it here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .