What Is an Affinity Score and Why Does it Matter?
IBM i consultant Dawn May describes the importance of affinity scores as a measure of performance and explains how to review that data
In a computer system, the closer the memory is to the processor, the better the performance.
On IBM Power, such optimization requires an understanding of the system’s non-uniform memory access (NUMA) architecture, which means memory can be local to the processor socket or remote on a different socket. Since it is faster to access local memory than remote memory, optimal performance requires local memory access.
That relationship between memory and processor is represented by affinity scores, a score of 100 being perfect and 0 being the weakest.
Conditions That Reduce Local Memory Access
When there are several partitions on the same physical server, the hypervisor automatically attempts to allocate memory locally on the node. But local memory access can be reduced—bringing down the affinity score—with the addition of another partition or dynamic LPAR (which can move CPU or memory resources between partitions), or when Live Partition Mobility (LPM) is in use.
When memory access is remote, the work dispatched to the CPU must wait for this remote memory access to complete. This ultimately shows up as a higher CPU utilization as the thread is dispatched on the physical CPU, even though it is delayed for remote memory access.
How to Review Your Affinity Score on IBM i
You can review your system’s affinity score on the HMC or by using IBM i performance data.
IBM i Collection Services has an undocumented file, QAPMSYSAFN, where there is a column, AFSCORE, that returns the affinity score. A simple query on this file can reveal the affinity score for your partition. (There’s much more information in this file, but that is beyond the scope of this post). If you use IBM iDoctor, you can also display the affinity score with additional information.
IBM also provides the Dynamic Platform Optimizer (DPO), which can be used to rearrange processors and memory to improve memory affinity. DPO can be run dynamically with no system downtime. However, DPO can impact the performance of the entire physical server (i.e., all partitions on that system), so if your environment is performance-sensitive, it is best to run DPO off-hours.
I encourage you to review the affinity score of your IBM i partitions to ensure it is optimal, and to use the Dynamic Platform Optimizer to correct it if not.
Finally, I also suggest the IBM i Performance FAQ as a resource. This document serves as a guide to performance concepts on IBM Power and IBM i, including very useful information on system affinity.