Thread pools group CPU resources, and contain threads used to execute Adaptive Server tasks associated with that thread pool. Threads host engines that execute user tasks, run specific jobs (such as signal handling), and process requests from a work queue. Adaptive Server contains system-defined thread pools and, if present, user-created thread pools.
Thread pools are available only when Adaptive Server
is configured for threaded mode.
Thread pools that contain engines are called engine pools, and perform Adaptive Server tasks that have a kernel process ID (KPID). Adaptive Server assigns an engine to each thread in an engine pool.
Adaptive Server supports two types of threads:
Engine (or multiplexed) threads – execute database query processes, and may be shared between multiple database processes. Multiplexed threads run tasks that share one or more threads with other tasks. By default, user and service tasks are multiplexed. Multiplexed tasks must yield after consuming a defined timeslice, or when blocked. Because all multiplexed threads are assigned an engine, they are equivalent to engines in process mode.
Run to completion (RTC) threads – used by system tasks and are not shared between multple tasks. An RTC thread runs a single task until the task completes, and is not subject to Adapative Server scheduling.
RTC threads run tasks that cannot remove themselves from a thread’s schedule until the thread completes, do not yield for timeslices, and remain connected to the thread while blocked. RTC tasks may need to wait for a thread to execute if all RTC threads are currently running tasks.
You cannot designate a thread’s type when you create the thread pool. User-created thread pools are always multiplexed.
Adaptive Server includes these system-defined thread pools:
syb_default_pool – the default engine thread pool. Each thread in syb_default_pool is an engine. All user tasks and all multiplexed system tasks (such as the housekeeper) run in syb_default_pool. However, you can move some tasks out of syb_default_pool by creating additional thread pools.
syb_system_pool – an RTC thread pool used for system threads. Each thread in syb_system_pool is dedicated to running a specific task. syb_system_pool contains at least one thread for the system clock and other asynchronous signals. All I/O handling threads run in syb_system_pool.
syb_blocking_pool – an RTC pool Adaptive Server uses to process blocking call requests from multiplexed tasks, which are normally operating system calls that may cause a multiplexed—or engine—thread to block for an unacceptable amount of time. Threads in syb_blocking_pool typically consume very few CPU resources.
Thread pools are defined by their attributes, some of which are automatically assigned by Adaptive Server, and that others are determined when you create the thread pool. The thread pool attributes are:
ID – a thread pool’s system-assigned ID. Adaptive Server may assign new IDs to thread pools during start-up, so Sybase recommends that you do not make static references to thread pool IDs.
Name – thread pool name. Only system thread pools can start with the syb_ prefix.
Description – (Optional) thread pool description, up to 255 characters.
Type – is one of Engine
or RTC
.
Current number of threads – the number of threads the pool currently contains (may differ for a short period of time from the configured number of threads in the pool while the pool is changing sizes).
Configured number of threads – the number of threads for which the thread pool is configured.
idle timeout – the amount of time, in microseconds, after a thread becomes idle before it goes to sleep.
Adaptive Server records the thread pool configuration in the configuration file. This example shows the three default thread pools (syb_blocking_pool, syb_system_pool, and syb_default_pool) and a user-created thread pool named big_pool:
[Thread Pool:big_pool] description = Big thread pool number of threads = 15 [Thread Pool:syb_blocking_pool] number of threads = 20 [Thread Pool:syb_default_pool] number of threads = 1
Use sp_helpthread, or the monThreadPool monitoring table, to view the current thread pool configuration. Edit the thread pool information in the configuration file before starting Adaptive Server or use alter thread pool to a change the thread pool configuration.
See Chapter 3, “Configuring Memory,” in the System Administration Guide: Volume 2.