Specifying how threads in a PE execute operators
Within a processing element (PE), Teracloud® Streams can use threads to execute operators in parallel to achieve better performance. The threading model of a PE determines how threads execute operators. When you submit a job, you may change the threading model for all of the PEs in an application.
About this task
The threading model for your application might be specified directly in the SPL application
through the @threading
annotation or by the default threading model that is
configured at the domain or instance level. When you submit a job, you can override the existing
threading model by specifying the threadingModel submission-time configuration
parameter.
You do not need to recompile your application to change the threading model when you submit the job.
You can override the threading model by using a job configuration overlay file or from
the Teracloud® Streams
Console or the streamtool submitjob
command.
@threading
annotation: - manual
- Each operator input port is executed by the thread that executed the upstream operator, unless the application programmer manually adds a threaded port to an operator input port.
- dynamic
- Each operator input port can be executed by any thread. The assignment of threads to input ports
can change at runtime, as can the number of available threads. If you set the threading model to
dynamic, you can also configure the following options:
- The dynamicThreadingThreadCount parameter specifies the number of threads
to start with. The value must be an integer greater than or equal to 1.
If you do not specify a value for this parameter, Teracloud® Streams uses the default value that is configured for the instance on which you deploy the application. If the instance does not have a default value, then the PE uses the default value for threads in the
@threading
annotation. - The dynamicThreadingElastic
parameter specifies whether the number of dynamic threads as well as the number of operators under
the dynamic threading model can change at runtime to maximize throughput. Specify
true to make elastic adjustment or false to keep the
number of dynamic threads and the number of operators under the dynamic threading model static.
If you do not specify a value for this parameter, Teracloud® Streams uses the default value that is configured for the instance on which you deploy the application. If the instance does not have a default value, then the PE uses the default value (true) for elastic in the
@threading
annotation.
- The dynamicThreadingThreadCount parameter specifies the number of threads
to start with. The value must be an integer greater than or equal to 1.
- automatic
- During PE initialization, the SPL runtime chooses between the dynamic threading model and the manual threading model.
- dedicated
- Each operator input port has a dedicated thread that processes all tuples on that input port for that operator.
For a full description of threading models, see the SPL
@threading
annotation reference information.
If you do not specify a threading model, Teracloud® Streams uses the default threading model from the instance on which you deploy the application
(instance.threadingModel). If the instance.threadingModel
is not set, the default value (automatic) for model in the
@threading
annotation is used.