Question: Patterns for Parallelization?
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 335
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 6
Description
So it's not fully clear reading the wiki nor examples if this is supported for scatter-gather scenarios inside orchestrations so bringing it up here.
We have a set of work item that need to be done in total but they don't have any requirement for being serially processed. Just the orchestration has to have them all complete prior to finishing.
So lets say we have this naive orchestration that schedules a task per input (doesn't really matter) and when they are all done, it completes.
```csharp
public class Orchestration : TaskOrchestration>
{
public override async Task RunTask(OrchestrationContext context, List input)
{
foreach (var thingToDo in input)
{
await context.ScheduleTask(typeof(DoWorkTask), thingToDo);
}
return "done";
}
}
```
So in a short execution time for DoWorkTask with a short enough set of inputs, serialized execution doesn't matter. However let's postulate that DoWorkTask averages say 1 hour of execution time. In addition we regularly have 20 or 30 "DoWorks" we need to perform together. However, if each DoWork didn't care about anything else and wouldn't interfere can we schedule multiple tasks and then await?
Basically something along this naive example (assume there's a extension method to build the parallelized partitioned work for brevity)
```csharp
public class Orchestration : TaskOrchestration>
{
public override async Task RunTask(OrchestrationContext context, List input)
{
foreach (List> partitionedWork in input.Partition(5)) // Do up to 5 things in parallel
{
var tasks = new List();
foreach (var thingToDo in partitionedWork)
{
tasks.Add(context.ScheduleTask(typeof(DoWorkTask), thingToDo));
}
await Task.WhenAll(tasks);
}
return "done";
}
}
```
so this is the type of thing we're checking for supported use
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.