numactl is a Linux utility that provides control over NUMA (Non-Uniform Memory Access) policy for processes or shared memory. NUMA is a computer memory design in which the memory access time depends on the memory location relative to a processor. numactl allows the user to specify which NUMA node a process should run on, as well as which memory should be allocated from for the process. This can be useful for optimizing performance and reducing latency in multi-node NUMA systems.
By default, processes run on the first NUMA node, and memory is allocated from the system-wide memory pool. numactl provides options to specify NUMA policy at the process level, such as which NUMA node the process should run on, or which NUMA node should be used for allocating its memory. numactl also provides options for controlling the memory policy for shared memory, such as interleave policy and memory binding.
numactl can be useful for improving performance for applications that have specific NUMA requirements or for applications that experience performance degradation due to the NUMA architecture of the system. By specifying the NUMA policy for a process or shared memory, numactl can help minimize latency and increase overall system performance.
If you encounter the below error while running the command numactl:
numactl: command not found
you may try installing the below package as per your choice of distribution:
|Debian||apt-get install numactl|
|Ubuntu||apt-get install numactl|
|Arch Linux||pacman -S numactl|
|Kali Linux||apt-get install numactl|
|CentOS||yum install numactl|
|Fedora||dnf install numactl|
numactl Command Examples
1. Run a command on node 0 with memory allocated on node 0 and 1:
# numactl --cpunodebind=0 --membind=0,1 -- command command_arguments
2. Run a command on CPUs (cores) 0-4 and 8-12 of the current cpuset:
# numactl --physcpubind=+0-4,8-12 -- command command_arguments
3. Run a command with its memory interleaved on all CPUs:
# numactl --interleave=all -- command command_arguments