CPU architecture SMP / NUMA, Tuning

CPU architecture SMP / NUMA, Tuning

  • SMP: stands for "symmetric multiprocessing" (Symmetrical Multi-Processing) technology.

    It refers to a computer brings together a group of processors (multi-CPU), and a shared memory bus between the CPU.

    Weakness: CPU increases after, but only a memory and the memory controller, CPU is accessing memory through the memory controller, multiple CPU memory controller will generate competition, in order to avoid competition appeared NUMA architecture.

  • NUMA:Non Uniform Memory Access

    Each CPU has its own dedicated memory (scientific name node), but can also access other professional CPU memory, then performance will drop.

Under Linux NUMA-related commands

  • numastat: view the status of nodes.

    We can see the process under their own memory, CPU hit (node) how many times did not hit many times, if not the number of hits of how to do more? This will force the process to bind their own CPU.

    The classic scenario: the nginx worker processes to bind to a specific CPU architecture under numa, performance will be improved significantly.

  • numactl: you can realize the processes are bound to a particular CPU

    However, when the machine is restarted, the binding becomes ineffective. How to solve it, use numad

  • numad: daemon

  • numademo

Non-numa architecture, how the process is bound to a particular CPU then, use taskset

$ taskset -p -c 0,1,2-4,5,9 1234

The meaning of the above command: ip as the process of the process 1234, bind to No. 0, No. 1, No. 2, No. 3, No. 4, No. 5, No. 9 CPU.

This is just an example, it is generally bound to a CPU, but when the system reboots, you also need to re-bind, because pid has changed.

Nginx more powerful, which can be configured to bind the worker to which CPU, previously written to the configuration nginx configuration file.

Allows a process using the above method specially make a few CPU execution, but these CPU in addition to the implementation of this process, but also the implementation of the kernel, how to avoid to prevent these do not perform CPU core, only look at that process?

Solution: Suppose there are six CPU, system startup, just let two CPU cores execute instructions not to execute the remaining four core instruction.

Edit / etc / default / grub file, followed by quiet splash isolcpus = 2,3. Back to the terminal to perform update-grub. It will automatically in accordance with the just edited profile (/ etc / default / grub) generated as a boot program preparation profile (/boot/grub/grub.cfg)

Reference: processor affinity ubuntu in the process of testing and vCPU binding

Even aside a CPU, the CPU core reserved instruction is not dealt with, but also to handle interrupts ah, how to not let them interrupt CPU to handle it?

Modify / proc / irq / / Smp_affinity file

$ echo cpu_mask > /proc/irq/<irq_num>/smp_affinity

cpu_mask: expressed in bits.

0001:代表1号CPU
0011:代表1号和2号CPU
0101:代表1号和3号CPU

Non-numa architecture, how to determine which processes should be bound to a particular CPU it? How to determine which thread is frequent switching of it? The following command

sar -q
使用sar之前要配置一下
1,修改:/etc/default/sysstat, 将 ENABLED=“false“ 改为ENABLED=“true“
2,执行:sudo /etc/init.d/sysstat restart
top
w
uptime
wmstat 1 5
下面的是查看CPU的使用率
mpstat 1 2
sar -P 1 2
iostat -c 1
cat /proc/stat

Screenshot command iostat -c 1, the meaning of the view CPU usage

  • % User: CPU usage of user process
  • % System: kernel CPU usage
  • % Iowait: CPU utilization io processing
  • CPU utilization of virtual machines:% steal
  • % Idle: CPU idle
ys:~$ iostat -c 1
Linux 4.15.0-20-generic (ys-VirtualBox)         2019年09月27日  _x86_64_        (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.26    0.03    0.08    0.05    0.00   99.57


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

[Command] dstat more powerful, you can visually get the following information:

       --top-bio
           show most expensive block I/O process
           显示最消耗blockI/O的进程
       --top-bio-adv
           show most expensive block I/O process (incl. pid and other stats)
           显示最消耗blockI/O的进程
       --top-childwait
           show process waiting for child the most
           显示等待子进程时间最长的父进程
       --top-cpu
           show most expensive CPU process
           显示最消耗CPU的进程
       --top-cpu-adv
           show most expensive CPU process (incl. pid and other stats)
           显示最消耗CPU的进程
       --top-cputime
           show process using the most CPU time (in ms)
           显示最消耗CPU时间片的进程
       --top-cputime-avg
           show process with the highest average timeslice (in ms)
           显示最消耗CPU时间片的进程
       --top-int
           show most frequent interrupt
           显示最经常发生的中断信号
       --top-io
           show most expensive I/O process
           显示最消耗I/O的进程
       --top-io-adv
           show most expensive I/O process (incl. pid and other stats)
           显示最消耗I/O的进程
       --top-latency
           show process with highest total latency (in ms)
           显示等待时间最长的进程
       --top-latency-avg
           show process with the highest average latency (in ms)
           显示等待时间最长的进程
       --top-mem
           show process using the most memory
           显示使用内存最多的进程

Commands sar -w 1 (seconds)] more powerful, intuitive process of switching times in the average number of seconds specified in the

c / c ++ mutual learning QQ group: 877 684 253

I micro letter: xiaoshitou5854

Guess you like

Origin www.cnblogs.com/xiaoshiwang/p/11599492.html