Setting Up the Model Processing Sequence

In Plant Applications, by default and by design, all models execute in sequence. That is, a model must finish executing before the next model can start. An issue, however, is that a model that may take a few milliseconds to run would be forced to wait for a slower model to finish processing. To help resolve this, a method was needed that would provide the flexibility to allow some models to run sequentially and some models to run in parallel.

Multi-Thread Solution

To enable some models to run in parallel and other models to run sequentially, the following changes have been made to Plant Applications:

  • The Event Manager is multithreaded

  • The Database Manager is multithreaded

  • The Email Engine is multithreaded

  • The Model Processing Group field has been added to models

How It Works

Initially, the Event Manager uses two threads:

  • One thread is used for polling

  • One thread is used by model groups with a group number of 0 (zero)

NOTE: By default, all models are assigned model group number 0 (zero) and, therefore, all run sequentially.

Each model group gets its own thread and its own database connection. Models within groups are executed sequentially.

By default, multi-threading is turned on. You can turn off multithreading by editing the System User parameters for each of the three services (see the System Users topic) or by editing the Multithreaded site parameter. Note that system user parameters take precedence over site parameters.

Considerations

It is important to understand that multi-threading does not necessarily mean improved performance. When multiple models are executed at the same time, computer resources are shared. This may cause models running in parallel to run slower. While steps have been taken to prevent deadlocking, you may experience deadlocks, particularly when performing inserts or updates on one of your tables.

If deadlocking is detected by Plant Applications, an attempt will be made to re-run the stored procedure. Additionally, an error message will be written to the Event Manager or Database Manager log files.

Additionally, it is important to remember that each group gets its own thread and its own database connection. Too many threads could have a negative impact on performance.

Implementation

First, it is recommended that you determine the models that can be run in parallel and the models that must be run in sequence. Then, specify a number (up to six digits) for each group and enter that number in the Model Processing Group field for each model you want to group.

To enter a Model Processing Group number

  1. In the Plant Applications Administrator, expand Plant Model.

  2. Expand the appropriate department and production line.

  3. Right-click the production unit and click Configure Events on <production unit>. The Event Detection wizard appears.

  4. For more information, please see the Configuring Event Detection topic.

  5. Do one of the following:

  6. To group an existing model, select the model from the Configured Model list and click Edit Model.

  7. To group a new model, from the Model Type list select the model type that corresponds to the type of event you want to detect and then click Add New Model.

  1. On the General tab, type the group number in the Model Processing Group box. The Model Processing Group number can be up to six digits.

  2. Finish adding or editing the model and click to save the configuration.