Install
# RHEL / Alma / Rocky sudo dnf install numactl # Debian / Ubuntu sudo apt install numactl # openSUSE sudo zypper install numactl # Arch sudo pacman -S numactl
What it does
numactl controls CPU and memory placement policies on NUMA (Non-Uniform Memory Access) systems. It allows you to bind a process to specific NUMA nodes or CPUs to optimize performance.
How it works (mechanical)
- Interacts with Linux NUMA kernel subsystem.
- Sets memory allocation policy for a process.
- Can bind execution to specific CPUs or nodes.
- Works only on systems with NUMA architecture.
- Often used in database and high-performance workloads.
Quick Start
# Show NUMA topology numactl --hardware
10 Practical Examples
# 1) Display NUMA hardware layout numactl --hardware
# 2) Run process on node 0 only numactl --cpunodebind=0 --membind=0 ./myapp
# 3) Bind to CPUs 0-3 numactl --physcpubind=0-3 ./myapp
# 4) Prefer node 1 for memory allocation numactl --preferred=1 ./myapp
# 5) Interleave memory across nodes numactl --interleave=all ./myapp
# 6) Check process NUMA policy numactl --show
# 7) Combine with taskset for CPU pinning taskset -c 0-3 numactl --membind=0 ./myapp
# 8) Monitor NUMA stats numastat
# 9) Run database on specific NUMA node numactl --cpunodebind=1 --membind=1 mysqld
# 10) Debug performance imbalance numactl --hardware numastat
Notes & Gotchas
- Has no effect on single-node (non-NUMA) systems.
- Improper binding can degrade performance.
- Common in HPC, virtualization, and database workloads.
- Requires understanding of system NUMA layout.
- Combine with performance monitoring tools for best results.
Historical Context
As multi-socket and multi-core servers evolved, NUMA architectures required software-level memory and CPU awareness. numactl became a standard tool for tuning performance-critical workloads.
Modern Equivalent
Modern orchestration systems (Kubernetes, systemd resource control) can manage CPU and memory affinity automatically. However, numactl remains essential for manual tuning and diagnostics.
Related Commands
- taskset — set CPU affinity.
- numastat — show NUMA statistics.
- lscpu — display CPU architecture.
- free — show memory usage.
- htop — monitor CPU usage.