数据库服务端及客户端绑核

0、绑核

openGauss数据库服务端及客户端绑核

yum install numactl

numactl -H

numactl -H is a command used to display the hardware information of the NUMA (Non-Uniform Memory Access) nodes on a system. NUMA is a memory architecture that allows multiple processors or cores to access their own local memory as well as a shared memory pool.

The output you provided shows the details of the NUMA nodes and their characteristics:

  • available: 4 nodes (0-3): Indicates that there are four NUMA nodes numbered from 0 to 3.

For each node, the following information is provided:

  • node X cpus: Lists the CPUs (or cores) that belong to the particular NUMA node. In your example, node 0 has CPUs with IDs 0-23, node 1 has CPUs with IDs 24-47, node 2 has CPUs with IDs 48-71, and node 3 has CPUs with IDs 72-95.

  • node X size: Specifies the total size of memory available on the NUMA node. For instance, node 0 has a total size of 97577 MB (megabytes).

  • node X free: Indicates the amount of free memory available on the NUMA node. For example, node 0 has 93294 MB of free memory.

The last part of the output provides the distances between the nodes. It represents a matrix where each row and column corresponds to a specific node. The numbers denote the distance between the nodes, which can be useful for optimizing data access and minimizing latency in NUMA-aware applications.

For example, the distance between node 0 and itself is 10, between node 0 and node 1 is 12, between node 0 and node 2 is 20, and between node 0 and node 3 is 22. The distances are symmetric, so the distance from node 1 to node 0 is also 12, and so on.

Understanding the NUMA architecture and its distances is important for efficiently allocating resources and optimizing performance in systems with multiple processors or cores.

1、绑核的目的?

numactl 是一个用于管理 NUMA 架构系统的实用程序。NUMA(Non-Uniform Memory Access,非一致性内存访问)是一种多处理器架构,在这种架构中,系统中的各个处理器核心和内存被分割成多个节点,每个节点有自己的本地内存。

numactl 的目的是允许用户显式地控制进程在 NUMA 系统中的内存访问行为和核心绑定。通过将进程绑定到特定的核心或节点,可以优化内存访问,减少远程访问延迟,提高应用程序的性能。

以下是 numactl 的一些常见用途和目的:

  1. 优化内存访问性能: 通过将进程绑定到某个特定的节点或核心,可以使该进程更有可能从本地节点的内存中获取数据,而不是通过远程访问获取数据。这可以降低访存延迟,提高应用程序的整体性能。

  2. 减少缓存争用: 绑定进程到特定核心或节点可以减少不同核心之间的缓存争用。这是因为不同核心共享同一个节点的内存,当多个核心同时访问同一节点中的内存时,可能会导致缓存争用问题。绑定进程可以将其限制在某个节点或核心,减少与其他核心之间的竞争。

  3. 控制内存分配和迁移: numactl 还可以用于控制内存分配和迁移策略。通过设置相应的选项,可以指定内存分配和迁移的行为,以满足特定的性能需求。例如,可以将内存绑定到特定的节点,或者限制内存迁移来减少系统中的干扰。

总的来说,numactl 的目的是帮助用户优化 NUMA 架构系统上的应用程序性能,通过控制进程的核心绑定和内存访问行为来减少延迟、缓存争用和内存分配/迁移开销。

2、如何绑核?

使用numactl命令可以在Linux系统上绑定核心。numactl是一个工具,用于控制非均匀内存访问(NUMA)系统的内存和CPU策略。

要使用numactl绑定核心,可以使用以下命令:

numactl --physcpubind=<cpu_list> <command>

其中:

  • --physcpubind选项用于指定要绑定的核心列表。
  • <cpu_list>是一个逗号分隔的核心列表,例如,"0,2,4"表示绑定核心0、2和4。
  • <command>是要运行的命令。

例如,如果要将进程绑定到核心0和核心1,可以使用以下命令:

numactl --physcpubind=0,1 <command>

这将使<command>在核心0和核心1之间进行调度。

请注意,numactl需要在支持NUMA的系统上安装和使用,并且可能需要root权限才能生效。

3、numa?

与NUMA相关的工具

numastat -h
numastat: invalid option -- 'h'
Usage: numastat [-c] [-m] [-n] [-p <PID>|<pattern>] [-s[<node>]] [-v] [-V] [-z] [ <PID>|<pattern>... ]
-c to minimize column widths
-m to show meminfo-like system-wide memory usage
-n to show the numastat statistics info
-p <PID>|<pattern> to show process info
-s[<node>] to sort data by total column or <node>
-v to make some reports more verbose
-V to show the numastat code version
-z to skip rows and columns of zeros
numactl -h
numactl: invalid option -- 'h'
usage: numactl [--all | -a] [--interleave= | -i <nodes>] [--preferred= | -p <node>]
               [--physcpubind= | -C <cpus>] [--cpunodebind= | -N <nodes>]
               [--membind= | -m <nodes>] [--localalloc | -l] command args ...
       numactl [--show | -s]
       numactl [--hardware | -H]
       numactl [--length | -l <length>] [--offset | -o <offset>] [--shmmode | -M <shmmode>]
               [--strict | -t]
               [--shmid | -I <id>] --shm | -S <shmkeyfile>
               [--shmid | -I <id>] --file | -f <tmpfsfile>
               [--huge | -u] [--touch | -T]
               memory policy | --dump | -d | --dump-nodes | -D

memory policy is --interleave | -i, --preferred | -p, --membind | -m, --localalloc | -l
<nodes> is a comma delimited list of node numbers or A-B ranges or all.
Instead of a number a node can also be:
  netdev:DEV the node connected to network device DEV
  file:PATH  the node the block device of path is connected to
  ip:HOST    the node of the network device host routes through
  block:PATH the node of block device path
  pci:[seg:]bus:dev[:func] The node of a PCI device
<cpus> is a comma delimited list of cpu numbers or A-B ranges or all
all ranges can be inverted with !
all numbers and ranges can be made cpuset-relative with +
the old --cpubind argument is deprecated.
use --cpunodebind or --physcpubind instead
<length> can have g (GB), m (MB) or k (KB) suffixes

4、允许容器使用的CPU核

https://weread.qq.com/web/reader/57f327107162732157facd6?

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/hezuijiudexiaobai/article/details/131664116