Knowledge points that must be mastered in performance testing: concurrency and parallelism, as well as CPU status and core parameters

 

Performance testing must be inseparable from concurrency and parallelism, and concurrency and parallelism are inseparable from the CPU. This article will give you an in-depth understanding of what concurrency and parallelism are, as well as the status and core parameters of the CPU.

Concurrency and Parallelism

Usually, a CPU has several cores, and several processes (threads) can be executed in parallel. A concept is emphasized here. What we usually call concurrency is concurrent in English, which means that several tasks seem to be executed at the same time during a period of time (multi-core is not required); while parallelism is parallel in English, tasks must be executed at the same time (requires multi-core).

For example, a 3-core CPU seems to have 3 pipelines, which can execute 3 tasks in parallel. The execution process of multiple threads of a process will generate a race condition, as shown in the following figure

CPU main parameters

In the Linux system, we can obtain the main parameters of the CPU through the top command:

The meanings of the main parameters are as follows: 

us (user), that is, the percentage of CPU usage in user space.

sy (system), that is, the CPU usage ratio of the kernel space.

ni (nice), nice is used by the Unix operating system to control the priority of the process. -19 is the highest priority, 20 is the lowest. This represents the percentage of CPU used by processes with adjusted priorities.

id (idle), the proportion of idle CPU.

wa (I/O Wait), I/O Wait idle CPU ratio.

hi (hardware interrupts), the percentage of CPU used in response to hardware interrupts.

si (software interrupts), the proportion of CPU usage in response to software interrupts.

st (stolen), if the current machine is a virtual machine, this indicator represents the proportion of CPU time stolen by the host. For a host with multiple virtual machines, the host can steal CPU time from any one of the virtual machines.

load average - average load. Load can be understood as the number of processes being queued for execution at a certain moment divided by the number of CPU cores. Load averaging requires multiple samples to be averaged. If the value is greater than 1, the CPU is quite busy.

 CPU status

The user space program corresponds to the parameter us

The kernel space program corresponds to the parameter sy

The interrupt program corresponds to the parameters hi and si

Idle corresponds to the parameter id

I/O corresponding parameter wa

Stolen corresponding parameter st

Every article of mine hopes to help readers solve problems encountered in actual work! If the article helped you, please like, bookmark, forward! Your encouragement is my biggest motivation to keep updating articles!

Guess you like

Origin blog.csdn.net/liwenxiang629/article/details/132018244