In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to use the correct posture to view the CPU information of the host system, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
First, several concepts about CPU
The role of CPU
The central processing unit (CPU) in the computer performs basic computing work-running programs. However, a single-core CPU can only perform one task at a time. In order to improve the processing power of the computer, the technologies of multi-CPU, HT and multi-core CPU have emerged.
Most computers have only one physical CPU. A single CPU may have multiple cores or hyperthreading technology, but there is still only one physical CPU plugged into a single CPU slot on the motherboard. Before the advent of hyperthreading and multicore CPU, people tried to add extra processing power to computers by adding extra CPU. This requires a motherboard with multiple CPU slots-insert multiple CPU into different slots. The motherboard also requires additional hardware to connect these CPU slots to RAM and other resources. There is a lot of overhead-if the CPU needs to communicate with each other, there will be additional latency, a system with multiple CPU will consume more power, and the motherboard will require more sockets and hardware and circuits.
It is rare to have multiple cpu on personal pc, but on today's servers, physical cpu is generally 2 standard. Because the server needs more processing power.
Hyperthreading (Hyper-Threading, referred to as "HT") technology is the use of special hardware instructions to simulate two logic cores into two physical chips, so that a single processor can use thread-level parallel computing, and then compatible with multi-threaded operating systems and software, reducing the idle time of CPU and improving the running efficiency of CPU.
Hyperthreading of CPU (HT)
Hyper-threading technology is that a CPU executes multiple programs at the same time and shares resources in a CPU. In theory, it is necessary to execute two threads at the same time as two CPU. Although hyper-threading technology can execute two threads at the same time, it is not like two real CPU, each CPU has independent resources. The CPU is still a single CPU, while the operating system sees two CPU, and when both threads need a resource at the same time, one of them temporarily stops and gives up the resource until the resource is idle. Therefore, the performance of hyperthreading is not equal to the performance of two CPU.
Multicore CPU
Initially, CPU had only one core. This means that the physical CPU has a single central processing unit. To improve performance, manufacturers add additional "core" or central processing units. Dual-core CPU has two central processing units, so the operating system appears to be two CPU. Different processes can use each core at the same time. This can speed up the processing speed of the system because the computer can perform multiple tasks at the same time.
Unlike hyperthreading, dual-core CPU actually has two central processing units on CPU chips, four-core CPU has four central processing units, eight-core CPU has eight central processing units, and so on. This helps significantly improve processing performance while keeping physical CPU units miniaturized and better suited to a single slot. Only a single CPU slot can be inserted into a CPU unit-instead of four different CPU slots, four different CPU, each requiring its own power, cooling and other hardware connection consumption. Because they are all on the same chip, all have less latency and the core can communicate faster.
Second, how to correctly check the number of cpu on the host?
Total number of cores = number of physical CPU * number of cores on each CPU
Number of buses (logical CPU) = number of physical CPU * number of cores per CPU * number of threads or buses per core (number of logical CPU) = total number of cores * threads per core
Note: "threads" here are not the same as "threads within the operating system". From cpu's point of view, a thread (short for "thread of execution") is just an ordered sequence of instructions telling the computer what to do.
The first way:
Check the number of physical cpu on the host
[root@localhost ~] # cat / proc/cpuinfo | grep "physical id" | sort-u | wc-L2
Check the number of cores on each cpu on the host
[root@localhost ~] # cat / proc/cpuinfo | grep "cpu cores" | sort-ucpu cores: 4
View the total number of logical CPU on the host (mode 1)
[root@localhost ~] # cat / proc/cpuinfo | grep "core id" | wc-L8
Quick view of the total number of logical CPU on the host (mode 2)
[root@localhost] # nproc-- all8
Quickly view the total number of logical CPU on the host (mode 3)
[root@localhost ~] # getconf _ NPROCESSORS_ONLN8
Quickly view the total number of logical CPU on the host (mode 4)
[root@localhost ~] # cat / sys/devices/system/cpu/online0-7
Remarks: 0-7: from 0 to 7
The second way:
Use the lscpu command
[root@localhost] # lscpu... Omit output CPU (s): 8On-line CPU (s) list: 0-7Thread (s) per core: 1Core (s) per socket: 4Socket (s): 2
... Omit output
Model name: Intel (R) Xeon (R) CPU E5620 @ 2.40GHz
The following information can be seen from the above:
Socket (s): number of physical cpu 2
Core (s) per socket: 4 cores per CPU
Thread (s) per core: 1 thread per core
CPU (s): total number of logical CPU
So the maximum number of threads (logical CPU) on this machine is: 2 CPU * 4 Cores * 1 threads = 8 threads
Hyperthreading technology is not enabled above. If hyperthreading (HT) is enabled, it should be 2 CPU * 4 Cores * 2 threads = 16 threads.
The following figure shows the details of the above processors. If you are also uncertain about the number of cores on your server, you can first go to the official website to query:
In addition, how to determine whether the host has enabled HT technology in the system? Please continue to look down
The first way:
Lscpu command
[root@localhost] # lscpu... Omit output CPU (s): 8On-line CPU (s) list: 0-7Thread (s) per core: 1Core (s) per socket: 4Socket (s): 2. Omit output
If Thread (s) per core is 1, hyperthreading is disabled or the CPU does not support hyperthreading. If 2, HT is enabled.
The second way
[root@niunyun ~] # grep-E "cpu cores | siblings | physical id" / proc/cpuinfo | xargs-n 11 | sort-uphysical id: 0 siblings: 8 cpu cores: 4physical id: 1 siblings: 8 cpu cores: 4
From here, siblings is twice as large as cpu cores, which indicates that hyperthreading is enabled. If HT is not enabled, it is the same number.
After reading the above, do you have any further understanding of how to view the CPU information of the host system in the correct posture? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.