The number of processes that the CPU can handle and host in a certain amount of time is limited, which is directly related to the performance of the CPU, or this value marks the performance of the CPU, which is reflected in the actual use of the computer to be higher performance CPU can process more process content at the same time.
So, generally when you go to the computer city to buy personal computers, shopping guide will ask you about the general purpose of the computer, in fact, they are to help you calculate the computer performance you need, including the calculation of the maximum CPU load value, of course, they will not be so to calculate, but according to the price, Because high-priced CPUs tend to perform better, and then they ask you about the budget, and when they know that you're buying a computer, they already have a budget for you, and if your budget is higher than their budget, congratulate the guy who sells the computer and he can make more money. Therefore, to buy a computer must be based on actual needs, such as CPU support is very high load, and you in the actual use is not up to that high load, that does not become a kill chicken with a pig knife.
The
pulls away, after all, the higher the number of processes the CPU can handle in a unit of time, the higher its performance should be. But about this load, there are many kinds of information on the Internet, some say that the load should not exceed the core of the CPU, some say should not exceed the CPU core number of twice times, some say should not exceed the CPU core number of 3 times times, why there are so many statements, in fact, we are worried about a phase The same problem----afraid of CPU can't carry, here super not more than several times does not matter, the most important criterion is that your CPU in a certain degree of load is not the system and applications are still running well, that is, the standard of judgment is also related to the actual application, If the CPU load is over the core number several times but the software is still running smoothly, that is also possible. Here to talk about the CPU running queue, the status parameters about the running queue can be viewed through the vmstat command, there is not much to explain, it has two, one is run, one is blocked, that is, Vmstat to see the first two rows, run represents the CPU inside the execution, Blocked representative because of disk or other bottlenecks caused him to wait in the CPU, these two values and the use of uptime or top command to see the system load value is very related, basically, the system at a certain time the load value is equivalent to the value of run plus the value of blocked, However, it is not right to use addition to express this, the system load value is an average, can be a decimal, and the number of running queues is an integer. In the case of idle CPU, run+blocked generally close to 0, occasionally jumping out of a 1 Ah 2 ah, so the load average idle state is generally 0.
However, when the load of the system gradually increased, that is, the CPU is running more and more things, then the reaction to the load mean its value will gradually increase, and can be very large, completely outside the CPU core number of many times, For example, I used a 8-core machine in the previous days to test the top command to see the load value reached nearly 600, which is far beyond the CPU can withstand the range, then why has exceeded the acceptable range of this load mean can also rise to that high, this is because in the CPU, The number of processes that can run at the same time is limited, that is, vmstat see the maximum number of run values, but blocked can continue to grow, because the process has been blocked off, it almost takes up a lot of CPU resources, and the run is not the same, A CPU at the same time can run how much depends on its physical performance, so when your machine load is constantly rising, you use the top command to see the load value will continue to rise, and when the load reaches a certain height, the CPU can handle the queue also reached the upper limit, the value of run no longer increases, at this time, The value of the blocked continues to increase, and in theory, the blocked can be increased until the system crashes.
Summary: In the evaluation of the performance of the CPU is completely copied online said several times is not accurate, but also you have to see the vmstat display of the run value and blocked value, when there are significantly more blocked, it shows that the CPU has produced a bottleneck. The load mean displayed by the top command and the uptime command can only be used as a reference for judging the state of the system in the past time period, which is not related to the performance of the CPU.
Context Switches
Context switches per Second: Number of thread transitions per second, translated into context switches in some books, actual meaning is task switching, or CPU hosting
Switch the contents of the converter. When the multi-tasking kernel decides to run another task, it saves the current state (context) of the running task, which is all within the CPU register
Capacity. The content is saved in the current state of the task's save area (task's Context Storage area), which is the task's own stack. Finished working on the stack
Later, the current state of the next task to be run is re-loaded from the task's stack into the CPU register and the next task is started. This over
Process is called task switching. The task switching process increases the additional load on the application. The more internal registers of CPUs, the heavier the additional load. What you need to do the task switching
Time depends on how many registers the CPU has to go into the stack.
Extended reading: cpu-context switches, running queues and usage
Extended reading: Process scheduling
Run queue vs. process queue