Caches, NUMA and memory locality A worker moves away from its data A batch worker changes seats. Its data stays where it was first allocated. From across the machine the program executes the same instructions, yet spends more time waiting for each batch of loads. Across a hundred sampled accesses, five go to a remote NUMA node in the reference run. After a placement change, seventy-one do. That's a change in where loads travel, not a change in the number of records the job was asked to process. A cache line is the unit moved between CPU caches. Two cores that write different counters on the same line can repeatedly invalidate each other’s copy. Worker core in context At a larger scale, NUMA makes the cost of a memory access depend on where a page lives relative to its CPU. Adding threads can multiply both effects. NUMA nodes attach memory closer to some CPUs. First-touch allocation and later thread migration can separate a worker from its data. Measure the actual placement. Independent counters on one cache line can force coherence traffic among writing cores. Padding or per-core aggregation trades a larger memory footprint for fewer invalidations. Larger pages extend TLB coverage. They can also waste space or introduce allocation and compaction delays. Compare tail behavior and translation misses under the intended policy. Draw two sockets, one memory bank beside each. A worker on the left initializes a large array, then a worker on the right repeatedly processes it. With a local first-touch policy, many pages may have landed near the first worker. Pinning the second worker more tightly on the right cannot bring those existing pages along. Find the page as well as the thread Two independent counters happen to occupy the same cache line. Coherence grants A write ownership and invalidates other cached copies. B must obtain ownership of that same line even though it updates a different counter. Separate hot writers onto distinct cache lines, then measure coherence traffic and throughput. If each core contributes one local counter and a coordinator merges them once per second, the hot writers avoid ownership transfer on every increment. The published total may now lag and the memory footprint grows. Ask how fresh the counter must be and whether merging creates a new bottleneck. The better design follows the sharing requirement, not just the speed of one isolated increment. Read the measurements Now give two threads independent counters inside the same cache line. Both update different numbers correctly. Each update can still force the line's writable ownership to travel between cores. Increasing the distance between those hot counters tests false sharing; changing physical page placement tests a different mechanism. Remote accesses per hundred samples describe the sampled population. A different workload can change the mix of reads and writes without changing placement at all. Use the same input, affinity, thread count and warmup, and confirm the sampling event means the same thing on the hardware under test. Move a worker or move its data? Would moving the worker back be equivalent to migrating every allocated page to its new node? Both can improve locality, but they move different resources. Compare the allowed CPUs, actual running CPUs and physical page placement. An ordinary cache miss can still be satisfied by local memory. If page placement is local, look for false sharing and memory bandwidth saturation before moving the process again. Check the competing explanation Sequential streams can benefit from prefetching, but simultaneous streams may saturate memory bandwidth. Extra threads can then increase contention without increasing useful throughput. A cache hit, remote memory access and storage read operate at different scales. Measure representative hardware and access patterns before using a memorized latency to size a service. After a placement change a worker spends longer waiting on loads although total CPU use looks similar. Compare local and remote allocations alongside the CPUs where the threads actually run. Moving a thread leaves its already allocated pages behind. Changing placement before the hot pages are first touched can keep both together. Measure the same working set again Coordinating placement before first touch brings the remote sample count down to nine per hundred. Private and shared caches reduce average access latency when a working set has locality. Once a workload outgrows a level, the miss penalty can dominate instruction count. Keep the data volume and worker count comparable. A placement plan describes two things, the computation and its memory. Apply the diagnosis Run the same job with the same amount of data while changing only initialization locality. Record where the threads ran and where the pages actually resided. A startup policy change usually applies to later allocations; already populated pages may remain elsewhere. A utilization change with no placement evidence leaves both explanations open.