NUMA-Aware Scheduling
What you'll learn: How operating systems optimize process placement on Non-Uniform Memory Access (NUMA) systems by considering memory locality.
The Problem: Not All Memory is Created Equal
In a NUMA (Non-Uniform Memory Access) system, multiple processors each have their own local memory. A processor can access its own local memory quickly, but accessing another processor's memory takes longer—sometimes 2-3 times slower. This creates a performance challenge: where should the scheduler place processes?
The Core Idea
NUMA-aware scheduling means the OS scheduler tries to run processes on CPUs that are close to the memory where that process's data lives. Think of it like organizing a library: you want students sitting near the books they're actually reading, not across the building.
When a process runs on CPU 0 and its data is in CPU 0's local memory, everything is fast. But if the scheduler moves that process to CPU 3, suddenly every memory access becomes slower because it must travel across the interconnect to reach CPU 0's memory.
How It Works
The scheduler tracks which memory nodes (NUMA nodes) contain a process's pages. When deciding where to schedule a thread:
- Prefer local placement: Try to schedule on a CPU in the same NUMA node as the process's memory
- Balance carefully: Sometimes load balancing still requires moving processes, but the scheduler weighs the memory penalty
- Memory follows process: Some systems can migrate memory pages to follow frequently-scheduled processes
This builds on processor affinity—but instead of just preferring "the same CPU," NUMA-aware scheduling prefers "CPUs near my memory."
Key Takeaway: NUMA-aware scheduling optimizes performance on multi-socket systems by preferring to schedule processes on CPUs that have fast, local access to the process's memory, minimizing expensive remote memory accesses.