thePoet

I'm trying to understand what is happening at certain times in the running life of a workflow, and why certain processes take a long time to run the first time they are run, and not afterwards (I have a lot of theories, but I'd be interested in clarification and ways to get around them). This is some simple setup code:Code

Code Snippet

wfRuntime = new WorkflowRuntime();

ManualWorkflowSchedulerService manualWorkflow = new ManualWorkflowSchedulerService();

wfRuntime.AddService(manualWorkflow);

ExternalDataExchangeService des = new ExternalDataExchangeService();

wfRuntime.AddService(des);

cSharpService = new CSharpExternalDataExchange();

des.AddService((ITestExternalDataExchange)cSharpService);

wfRuntime.StartRuntime();

Type type = typeof(Workflow1);

wfInstance = wfRuntime.CreateWorkflow(type);

wfInstance.Start();

I don't think the workflow itself is very important to my question. It simply waits on an event, and and calls a function every time that event is triggered. The part I am interested in is that the first pass in the following code takes over half a second to run, and the second pass around 3 milliseconds.

Code Snippet

// Pass 1

cSharpService.TriggerBasicEvent(wfInstance.InstanceId);

manualWorkflow.RunWorkflow(wfInstance.InstanceId);

// Pass 2

cSharpService.TriggerBasicEvent(wfInstance.InstanceId);

manualWorkflow.RunWorkflow(wfInstance.InstanceId);

I'm guessing there is some sort of delay load/compiling going on here to cause this, however, if I change the code to this

Code Snippet

manualWorkflow.RunWorkflow(wfInstance.InstanceId);

// Pass 1

cSharpService.TriggerBasicEvent(wfInstance.InstanceId);

manualWorkflow.RunWorkflow(wfInstance.InstanceId);

// Pass 2

cSharpService.TriggerBasicEvent(wfInstance.InstanceId);

manualWorkflow.RunWorkflow(wfInstance.InstanceId);

it only improves the performance of the first pass slightly. So, we must be delaying load/compile until we access a branch of the forkflow, that makes a lot of sense for many uses, but I can't have that kind of performance problem in the middle of running my app. I need everything loaded and ready to go from the beginning. Is there a way to override the current behavior



Re: Windows Workflow Foundation Initial Load and Performance

Moustafa Ahmed

Hi,

You can’t override the internal execution behavior. Did you get the chance to read the WF Performance whitepaper published here: http://msdn2.microsoft.com/en-us/library/Aa973808.aspx. It talks about modeling guidelines and performance considerations for WF.

Thanks, --Moustafa






Re: Windows Workflow Foundation Initial Load and Performance

thePoet

Yes, I read through the document. It does a nice job covering the performance of individual tasks in a workflow, but doesn't cover the initial load performance. What we are finding is that the initial running of sections of a workflow can be very slow, even though the workflow itself has already be started. While this won't matter for a web server where your worried about the number of users, in our application, a simulation, suddenly taking half a second to load up part of the workflow that hasn't been visited yet will cause all kinds of problems.

I was really hoping there would be a way to tell the system not to delay load when you create the initial workflow instance.




Re: Windows Workflow Foundation Initial Load and Performance

lakeeast

The example I ran got some interesting results:

1. If the event is raised by C++/CLI code, the C# handler in the workflow got called after 24.0 milliseconds initially. All following events got handled after 1.7 milliseconds.

2. If the event is raised by C# code, the C# handler in the workflow got called after 21.3 milliseconds initially. All following events got handled after 1.5 milliseconds.

Any ideas on how to disable delayed load The code example was run on a Dell Precision 490 Quad-Core desktop. I personally believe that MS Workflow will be much more useful if the performance is more consistent.

Thanks!