Linux cores and threads

Cores vs Threads: How many threads should I run on this machine?

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 

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.

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).

Источник

[LINUX] (Beginner) What are cores and threads?

I’m using jobs, tasks, cores, threads, etc., but I don’t really understand the relationship between them.

No matter how much I am not a specialist in computers, what happened as a person studying informatics, so I summarized it briefly.

Conclusion

-** Threads, processes, jobs, tasks ** are ** concepts ** and components of the program itself —A process is the execution unit of a program, that is, ** the largest group of programs ** —Thread ⊂ Process —Jobs and tasks seem to be ** ambiguous ** -** Processor, core, CPU ** are ** physically present ** PC components —Processor = CPU —Core ⊂ CPU

Читайте также:  Узнать модель оперативной памяти линукс

In detail

Processes and threads

This is the easiest to understand. One or more threads are created in one process.

The process is the parent and the thread is the child.

Jobs and tasks

How it is used varies depending on the environment, and it seems that it is often ** ambiguous **. Was good. I used it properly, but it wasn’t a mistake.

For the time being, if it is a Linux system, —A job is a collection of multiple processes —Task is a general term for processes and threads

Processor, core and CPU

The composition that ** CPU (= processor) ** contains ** parts (core) ** that actually perform processing.

In reality, the core is recognized as a CPU and processes and threads are assigned.

[Question] Is the CPU with 6 cores and 12 threads 2 threads per core?

To be honest, I didn’t understand this area well, so I looked it up. The answer is No.

Since the core is the place where processes and threads are ** processed **, which thread is assigned to the core is a story after the process or thread is created.

So, first of all, it seems correct that the upper limit of threads that can be run in parallel is 12, and there are 6 cores to allocate it.

In other words. If the thread limit is 12, the process limit will inevitably be 12.

For example, if you use all 12 threads in 3 processes, you can think of an allocation method like this.

Process name Number of threads Example 1 Number of threads Example 2
A 4 6
B 4 4
C 4 2

Источник

Differences between physical CPU vs logical CPU vs Core vs Thread vs Socket

When we try to know a computer’s architecture and performance at CPU level using Linux commands like nproc or lscpu, we often find out that we are not able to properly interpret their results because we confuse terms such as physical CPU, logical CPU, virtual CPU, core, thread, socket, etc. If we add concepts like HyperThreading (not to be confused with multithreading), we are in a situation where we can not be sure how many cores our box has, we don’t understand why commands like htop indicate that we have 8 cpus when we thought we had bought a single quad-core processor, etc. In short, it’s a mess.

Читайте также:  Astra linux опыт внедрения

In order to clarify I will explain all these concepts using a pair of simple diagrams that I hope will help you to easily understand and never again have these doubts.

The origins: single core CPUs and HyperThreading

Before concepts such as multi-core, virtual or logical cpu would exist, back in the days of Pentium processors, most computers mounted on their motherboard a single chip of considerable size that we called microprocessor, processor or simply CPU. Only a few enterprise computers or larger servers that required more processing power could afford to mount 2 or more of these chips on the same board: they were multiprocessor systems. These chips communicated with other motherboard elements through a connector or socket. And the math was simple: so many connectors or sockets had a board, so many CPUs a computer could have at most. If you wanted more processing power, you just had to look for a motherboard with a larger number of these processors or wait for them to evolve to offer higher performance.

But then Intel realized that communications between the different processors of a multiprocessor system were very inefficient since they had to be done through the system bus, which usually worked at much lower speed. This frecuently caused bottlenecks that made impossible to make the most of the computing capacity offered by each CPU.

In order to improve this situation the HyperThreading technology was invented. HT is about duplicating some CPU internal components within the same chip, such as registers or first level caches so that information could be shared between two different execution threads without having to go through the system bus with the corresponding bottlenecks and loss of speed issues. This also allowed that if a process had to wait for an interruption, another process could continue to use the CPU without it being stopped.

This way it was possible to speed up several cumputing processes and began to offer processors with a greater overall performance than traditional ones. The operating system was kind of cheated because it was offered 2 virtual or logical cpus (LCPU) instead of single one as it was allowed to execute 2 processes “at the same time”. But it is important to remark that it was impossible to yield twice the processing power of a traditional processor, nor was it possible to offer full parallel processing capabilities.

Thus, from the point of view of Linux or any other operating system, a box with 1 single core processor but HT appears before our eyes as having 2 CPUs. But these are 2 logical cpus running within the same single physical cpu.

Читайте также:  Configuring dns for linux

One more twist: the emergence of multi-core architectures

But as I said in the previous section, although CPUs with hyperthreading offer more processing power, they can not perform as 2 complete and independent processors, so it was decided to go further miniaturizing all processor components and encapsulating them next to others in a single chip. Each of these encapsulated processors was called core, and it allowed to achieve faster communications between them by means of an internal bus sharing the same silicon. From that moment it was no longer necessary to turn to the system bus, much slower.

Unlike HT tehcnology, now we have multiple completely independent CPUs to all intents and purposes, one per core. Indeed, from a performance point of view it’s better to have a single multicore processor than the equivalent number of single core CPUs on the same board. Of course it would still be better to have 2 dual-core processors than one, but even better would be to have a single quad-core.

At the operating system level, a physical quad-core processor would be shown as a 4 cpu computer. But these would be 4 logical CPUs or non-physical LCPUs. If the processor additionaly offers HyperThreading technology, commands such as htop or nproc would indicate that there are 8 cpus in the system, but would perform lower than 8 cpus from a single octa-core processor without HyperThreading.

1 LCPU = 1 thread

Finally, often we’ll find processors featuring 4 threads, 2 threads per core and things like that. This is simply about the number of execution threads or processing jobs that can be run simultaneously, which is the equivalent of the processing capacity offered by a LCPU. If a processor allows 2 threads per core it means that it is HT. Otherwise it’s normal for the number of cores to match threads.

Logical CPU vs Virtual CPU

The virtual CPU term is comparable to logical CPU but it adds a certain nuance: it’s more framed in terms of computing virtualization. It refers to those cpus mapped to virtual machines from the underlying host hardware, wich can be physical or logical cpus, HT or not. Normally 1 logical cpu from host server is mapped to 1 virtual cpu inside virtual machine, so they are almost equivalent terms.

Источник

Оцените статью
Adblock
detector