Parallel Activity in Trident

Dec 8, 2010 at 9:15 PM

Hi,

I have a couple of questions on the parallel activity in Trident:

1. The ParallelActivity under the Windows Workflow, in Trident, seems to allow only 2 parallel activities by default. In order to have more than two parallel activities, should we nest parallel activities within one another?

2. I tried an alternate solution of changing the number of child sequences for a parallel activity in the source code in Microsoft.Research.ScientificWorkflow.TridentModel in ModelFactory.cs. In the function, FetchCompositeActivityModelByMeta(), I added more children activity and this allowed more parallel activities instead of 2 children. During execution, the activities get invoked ("Executing" message on monitor appears) simultaneously. However they seemed to execute only one at a time, one by one. I was not able see any interleaving of functions within the activities. Is this a limitation or is there some interleaving involved?

Appreciate your help.

 

Thanks,

Kavitha

 

Dec 9, 2010 at 1:06 PM

Hi Kavitha,
 
Please find the response to your questions below:
 
<<In order to have more than two parallel activities, should we nest parallel activities within one another>>
Correct, in case you want to execute more than two parallel activities concurrently, you need to nest the Trident ParallelActivity.
 
<<I was not able see any interleaving of functions within the activities. Is this a limitation or is there some interleaving involved>>
 ParallelActivity is a Trident composite activity (based on the WF Parallel activity) that allows you to run multiple activities in parallel. Strictly speaking, only one activity is running at any given time, but for most purposes you can consider them to be concurrent. The ParallelActivity activity lets you schedule two or more child SequenceActivity activity branches for processing at the same time.
 
Although branch SequenceActivity activities are scheduled to start processing at the same time, they do not start processing at the same time. Processing begins with the execution of one activity that is contained in one of the SequenceActivity branches. When that activity is completed, the next activity in sequence in another branch executes, and so on. Activity execution switches between the SequenceActivity branches, with one activity executing at a time until all the SequenceActivity branches finish executing. This completes the processing of the ParallelActivity activity. ParallelActivity does not guarantee the exact order of execution across the SequenceActivity branches.

Example:
If a SequenceActivity branch contains an activity such as a blocked DelayActivity activity, execution does not stop and wait for the activity to be unblocked. Instead, the next activity in sequence in the next SequenceActivity branch is executed. Although the SequenceActivity child branches are processed at the same time, the branch activities do not execute in a true concurrent manner. The Windows Workflow Foundation runtime uses one thread per workflow instance. All the separate branches in the ParallelActivity activity share the same single workflow instance thread. Therefore, only one activity of one branch executes at a time.


Please let us know if this helps in answering your questions. 
Regards,
Trident Support Team

Dec 9, 2010 at 9:36 PM
Edited Dec 9, 2010 at 9:36 PM

Hi,

Thank you. That answers my questions.

Regards,

Kavitha

Dec 18, 2010 at 8:42 PM

Hi,

With reference to my previous question on parallel activities, I tried running some parallel activity workflows using Trident. Your answer suggests there is possible interleaving between activities.

However, when I ran delay activities in parallel, each activity seemed to run one after the other for the set delay time (eg: 20 seconds) without interleaving.

Following are the notification messages (workflow name: parallelDelay) 

parallelDelay Created 3:08:54 

parallelDelay Changed 3:08:55

parallelDelay Started 3:08:55

SequentialWorkflowActivity_0 Executing 3:08:55

ParallelActivity_2 Executing 3:08:59

SequenceActivity_3 Executing 3:08:59

SequenceActivity_4 Executing 3:08:59

Delay Activity Executing 3:08:59

Delay Activity Executing 3:08:59

Delay Activity Closed 3:09:19

Delay Activity Closed 3:09:39

SequenceActivity_3 Closed 3:09:39

SequenceActivity_4 Closed 3:09:39

ParallelActivity_2 Closed 3:09:39

SequentialWorkflowActivity_0 Closed 3:09:39

parallelDelay Closed 3:09:39

In the above example, the first activity runs for 20 seconds (from 3:08:59 to 3:09:19). After this the second one runs for next 20 seconds(from 3:09:19 to 3:09:39) , without interleaving.

I also tried running some custom activities that used sleep to block, but I noticed that these also ran sequentially one after the other. I could not observe an interleaving in execution of activities. Since you mentioned in your example, that delay activities run with interleaving execution, could you please let me know, an example scenario, with the value for seconds in the delay activity, for which it runs with interleaving. Also would it be possible to observe this interleaving using the notification messages?

Really appreciate your help with this.

 

Thanks,

Kavitha

Dec 20, 2010 at 1:12 PM

Hi Kavitha,

We are looking into your question. We will keep you posted on the updates.

Please let us know in case you have any questions/concerns.

Regards,
Trident Support Team

Dec 21, 2010 at 2:44 PM

Hi Kavitha,
 
Please find the response to your questions below:
 
<<Could you please let me know, an example scenario, with the value for seconds in the delay activity, for which it runs with interleaving>>
 
We have uploaded a Sample Workflow package through which you can observe the interleaving execution of activities in a parallel block. Please download the sample workflow from the following link: http://tridentworkflow.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=189573. The Scenario used here is as follows:
 
Scenario 1:

     1. The First Sequential Activity contains a Delay Activity followed by the Condition AND activity.
     2. We have used a Timeout Duration of 20ms in the Delay Activity.
     3. The Second Sequential Activity contains a Condition AND Activity.
     4. The Input 1 & Input 2 of Condition AND in the Second Sequential Activity are set to True.
     5. The Result of Condition AND from the Second Sequential Activity are bonded to Input 1 and Input 2 of Condition AND activity in the First Sequential Activity.
     6. The Result in both the Condition AND activities are marked as workflow output.

While executing the workflow, the Delay Activity is the first activity to be executed. It is followed by the Condition AND in the second Sequential Activity. The Delay Activity is closed on the completion of the Timeout Duration, it is followed by the closure of the Condition AND in the second Sequential Activity. The Condition AND in the first Sequential Activity then starts executing.
 
On the completion of the execution of this workflow, on navigating to the Workflow Outputs pane in the Input Output Parameters tab, we observe that the Result for both the Condition AND activities is True. This implies that the Condition AND in the second Sequential Activity is executed prior to the execution of the Condition AND in the first Sequential Activity (Please note that by default the value of Input 1 and Input 2 is set to False on the Condition AND activity).
 
Scenario 2:
To test the Scenario 1, let us re-position the Delay Activity after the Condition AND in the first Sequential Activity. On the completion of the execution of this workflow, we observe that the Result of the Condition AND activity in the first Sequential Activity is False instead of True in the previous scenario. In this scenario, the Condition AND in the first sequential activity is executed first followed by the Condition AND in the second Sequential Activity. Thus it takes the default value of the Condition AND activity instead of using the value which is bonded with the Condition AND in the second sequential activity.
 
<<Also would it be possible to observe this interleaving using the notification messages?>>
 
Yes, it is possible to observe the interleaving using the notification messages. For your better understanding, we have uploaded the screenshots of the Notification Messages for Scenario 1 and Scenario 2. Please download it from the following path:
 
Scenario 1: http://tridentworkflow.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=189583
 
Scenario 2: http://tridentworkflow.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=189584
 
Please let us know if this helps in answering your questions.
 
Regards,
Trident Support Team

Apr 6, 2011 at 10:32 AM

Hi Kavitha,

We are marking this issue as closed. If you have any further query/concern you can get back to us.

Regards,
Support Team