Thread Pool

enable_thread_pool

Parameter description: Specifies whether to enable the thread pool function. This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: Boolean

  • on indicates that the thread pool function is enabled.
  • off indicates that the thread pool function is disabled.

Note: When the thread pool function is enabled, logical replication applications need to use the HA port to connect to the database.

Default value: off

enable_thread_pool_numa_locality

Parameter description: Specifies whether to localize new thread pool sessions based on the NUMA node of the CPU that receives the connection. This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

This parameter takes effect only when the thread pool function is enabled, kernel sockets are used, and enable_gazelle_performance_mode is set to off. After this parameter is enabled, openGauss obtains the receiving CPU of a connection by using SO_INCOMING_CPU, derives the NUMA node of the CPU, and dispatches the session to the ThreadPoolGroup on the same NUMA node. If the receiving CPU cannot be obtained or no ThreadPoolGroup matches the NUMA node, openGauss falls back to dispatching the session to the ThreadPoolGroup with the fewest sessions.

In Gazelle/KNET mode, session dispatching uses the NUMA identifier provided by Gazelle/KNET, and this parameter does not take effect. If the database build or runtime environment does not support NUMA, sessions are still dispatched using the original policy even when this parameter is enabled.

Value range: Boolean

  • on indicates that NUMA-local session dispatching in the thread pool is enabled.
  • off indicates that NUMA-local session dispatching in the thread pool is disabled.

Default value: off

thread_pool_attr

Parameter description: Specifies the detailed attributes of the thread pool function. This parameter is valid only when enable_thread_pool is set to on. Only the sysadmin user can access this parameter. This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: a string, consisting of one or more characters

This parameter consists of three parts: thread_num, group_num, and cpubind_info. The meanings of the three parts are as follows:

  • thread_num indicates the total number of threads in the thread pool. The value ranges from 0 to 4096. The value 0 indicates that the database automatically configures the number of threads in the thread pool based on the number of CPU cores. If the value is greater than 0, the number of threads in the thread pool is the same as the value of thread_num. You are advised to set the thread pool size based on the hardware configuration. The formula is as follows: Value of thread_num = Number of CPU cores x 3–5. The maximum value of thread_num is 4096.
  • group_num indicates the number of thread groups in the thread pool. The value ranges from 0 to 64. The value 0 indicates that the database automatically configures the number of thread groups in the thread pool based on the number of NUMA groups. If the value is greater than 0, the number of thread groups in the thread pool is the same as the value of group_num.
  • cpubind_info indicates whether the thread pool is bound to a core. The available configuration modes are as follows: 1. '(nobind)': The thread is not bound to a core. 2. '(allbind)': Use all CPU cores that can be queried in the current system to bind threads. 3. '(nodebind: 1, 2)': Use the CPU cores in NUMA groups 1 and 2 to bind threads. 4. '(cpubind: 0-30)': Use the CPU cores 0 to 30 to bind threads. 5. '(numabind: 0-30)': Use CPU cores 0 to 30 in the NUMA group to bind threads. This parameter is case-insensitive.

Default value: '16, 2, (nobind)'