Threading
From OpenSimulator
Contents |
Introduction
OpenSimulator is an extremely concurrent application. It uses a large number of threads in
- Persistent control loops (such as scene processing and inbound packet processing)
- Thread pools for shorter-lived processing (e.g. for handling many viewer requests or for processing script events).
- Runtime created threads for inbound processing (e.g. for passing UDP/HTTP data to OpenSimulator code).
- Timer events, such as that triggered to processing statical information to send to viewers (server frames per second, etc).
Persistent control loops
Thread pools
Each XEngine script engine will use an additional SmartThreadPool instance for its own internal operations, such as script event processing. As there is one XEngine script engine per region, this will also mean an additional thread pool per region.
General thread pool
By default, OpenSimulator uses a library known as the SmartThreadPool for thread pooling. One instance of this handles general server operations, such as viewer request processing. This is used across all regions hosted by that simulator.
You can see information on thread thread pool using the "show threads" command on the simulator console. It's also shown in the summary information logged by the simulator every 60 minutes.
Here is some example output.
Main threadpool (excluding script engine pools) Thread pool used : SmartThreadPool Max threads : 150 Min threads : 2 Allocated threads : 2 In use threads : 0 Work items waiting : 0
- Max threads - The maximum number of threads that will be used by this pool. If this limit is reached then further requests will have to wait for a thread to be returned to the pool.
- Min threads - The minimum number of threads that this pool will keep on hand even if no work is being performed.
- Allocated threads - The number of threads currently in the pool.
- In use threads - The number of threads currently performing tasks.
- Work items waiting - The number of work items waiting for another thread pool thread to become available.