thread_pool_sched_affinity
Support CLI: Yes
Support configuration file: Yes
Support dynamic modification: Yes
Scope: global
Parameter type: bool
Default value: OFF
Possible values: OFF and ON
By default, the thread group and NUMA affinity function is disabled in the thread pool plugin. The thread_pool_sched_affinity parameter can be used only when all NUMA nodes of the server are available to the mysqld process and the range of CPUs available to the mysqld process is not restricted using a method, for example, numactl.
- When thread_pool_sched_affinity is enabled and the thread_pool_sched_affinity_foreground_thread to thread_pool_sched_affinity_purge_coordinator parameters are not configured:
Thread groups (whose quantity is specified by thread_pool_size) start polling of the affinity with NUMA nodes on the server. For example, if the number of NUMA nodes on the server is a and the NUMA node IDs range from 0 to a-1, the nth thread group is bound to the n%ath NUMA node, where n%a is the remainder of n divided by a. All threads created in a thread group will also be affinitive to the NUMA node bound to this thread group.
- When thread_pool_sched_affinity is enabled and the thread_pool_sched_affinity_foreground_thread to thread_pool_sched_affinity_purge_coordinator parameters are configured:
Thread groups become affinitive to the CPU cores specified by the thread_pool_sched_affinity_foreground_thread parameter in polling mode. That is, when a new connection is established or a connection is migrated to a different thread group, the current threads are bound to the specified CPU cores in polling mode based on the thread group number. The six key background threads started by MySQL are bound to the CPU cores specified by thread_pool_sched_affinity_foreground_thread to thread_pool_sched_affinity_purge_coordinator.
This reduces the probability of cross-NUMA memory access in scenarios where one session is used to query specific data only and thereby improves query performance.