Understanding the Relationship Between Linux Threads, Cores, and CPUs, and Generating Timestamp Logs with RF from XML

Understanding the Relationship Between Linux Sockets, Cores, Threads, and CPUs

  • **CPU(s)**: Represents the total number of logical CPUs in the system. It is calculated by multiplying the number of physical CPU cores, the number of threads per core, and the number of physical CPUs in the system. For example, a system with 2 physical CPUs (Sockets), each with 4 cores (Cores), and each core supporting 2 threads (Threads) has a total of <span>2 x 4 x 2 = 16</span> logical CPUs.
  • Thread(s) per core: Refers to the number of threads that each physical core can handle simultaneously, achieved through hyper-threading technology. Hyper-threading allows a single physical core to simulate multiple logical cores, enabling it to process multiple threads at the same time, thus improving CPU utilization. For instance, some Intel processors allow each core to have 2 threads, meaning each physical core can execute instructions for two threads simultaneously, logically equivalent to having two CPUs.
  • Core(s) per socket: Indicates the number of cores contained in the CPU chip installed in each physical CPU socket. For example, common CPUs have 4, 8, or 16 cores, where the core count refers to the number of cores per Socket. Cores are the units within the CPU that actually execute instructions, with each core having its own arithmetic logic unit, cache, etc., allowing it to execute tasks independently.
  • **Socket(s)**: Refers to the number of slots on the motherboard for installing physical CPUs. Servers typically have multiple Sockets to accommodate multiple physical CPUs, thereby enhancing the system’s processing capability. For example, a dual-socket server has 2 Sockets, allowing for the installation of two physical CPUs, with each CPU in a Socket having its own independent cache, memory controller, etc.
  • **NUMA node(s)**: Non-Uniform Memory Access nodes. In multi-CPU systems, to improve memory access efficiency, memory is divided into multiple nodes (NUMA nodes), each closely associated with a set of CPU cores. Typically, each Socket corresponds to one NUMA node. CPUs within the same NUMA node can access local memory faster than memory from other NUMA nodes. The operating system attempts to allocate processes to CPU cores on the NUMA node where the required memory is located to reduce memory access latency.

In summary, these concepts are interrelated. <span>Socket(s)</span> determine the number of physical CPUs in the system, <span>Core(s) per socket</span> describes the number of cores in each physical CPU, <span>Thread(s) per core</span> further explains the number of threads each core can handle simultaneously, all of which collectively determine the number of <span>CPU(s)</span> in the system. Meanwhile, <span>NUMA node(s)</span> is a division of memory based on <span>Socket(s)</span> and system architecture to optimize memory access performance, enabling efficient operation of the system under complex multi-CPU and multi-core architectures.

Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Byte Order:                           Little Endian
Address sizes:                        39 bits physical, 48 bits virtual
CPU(s):                               8
On-line CPU(s) list:                  0-7
Thread(s) per core:                   2
Core(s) per socket:                   4
Socket(s):                            1
NUMA node(s):                         1
Vendor ID:                            GenuineIntel
CPU family:                           6
Model:                                142
Model name:                           Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Stepping:                             12
CPU MHz:                              2100.000
CPU max MHz:                          4200.0000
CPU min MHz:                          400.0000
BogoMIPS:                             4199.88
Virtualization:                       VT-x
L1d cache:                            128 KiB
L1i cache:                            128 KiB
L2 cache:                             1 MiB
L3 cache:                             6 MiB
NUMA node0 CPU(s):                    0-7

We can use the <span>lscpu -e</span> command to obtain the correspondence between CPU and Core on the current machine. For example, in <span>RDTH-Mini-130</span>, the correspondence is as follows:

root@automation:/home/automation# lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ   MINMHZ
  0    0      0    0 0:0:0:0          yes 4200.0000 400.0000
  1    0      0    1 1:1:1:0          yes 4200.0000 400.0000
  2    0      0    2 2:2:2:0          yes 4200.0000 400.0000
  3    0      0    3 3:3:3:0          yes 4200.0000 400.0000
  4    0      0    0 0:0:0:0          yes 4200.0000 400.0000
  5    0      0    1 1:1:1:0          yes 4200.0000 400.0000
  6    0      0    2 2:2:2:0          yes 4200.0000 400.0000
  7    0      0    3 3:3:3:0          yes 4200.0000 400.0000
root@automation:/home/automation#

In contrast, the correspondence for the <span>C236</span> server is as follows:

automation@automation:~$ lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ   MINMHZ
  0    0      0    0 0:0:0:0          yes 4700.0000 800.0000
  1    0      0    1 1:1:1:0          yes 4700.0000 800.0000
  2    0      0    2 2:2:2:0          yes 4700.0000 800.0000
  3    0      0    3 3:3:3:0          yes 4700.0000 800.0000
  4    0      0    4 4:4:4:0          yes 4700.0000 800.0000
  5    0      0    5 5:5:5:0          yes 4700.0000 800.0000
  6    0      0    6 6:6:6:0          yes 4700.0000 800.0000
  7    0      0    7 7:7:7:0          yes 4700.0000 800.0000
automation@automation:~$

Using Robot Framework to Merge Logs and Reports from XML Files with Timestamps

# So easy
rebot -h
rebot -T -R ./*.xml

# For Windows
$TIMESTAMP = Get-Date -Format "yyyyMMddHHmmss"
rebot --log log-$TIMESTAMP.html --report report-$TIMESTAMP.html -R ./*.xml

# For Linux
TIMESTAMP=$(date +%Y%m%d%H%M%S)
rebot --log log-$TIMESTAMP.html --report report-$TIMESTAMP.html -R ./*.xml

Leave a Comment