views:

357

answers:

1

I am trying to execute some logic on multiple AppDomains in parallel. I am doing this because I am working with legacy code which is "un-changeable" and I want to improve performance by parallelizing some things. The problem is that if I run multiple instances within 1 AppDomain they all rely on some static data structures and interfere with eachother.

My implementation is simple. I want to run multiple instances of my "ExecutionHarness" class - each in their own AppDomain - so I created a class "ExecutionHarnessProxy : MarshalByRefObject" which I instantiate in each of my AppDomains (since ExecutionHarness doesn't inherit from MarshalByRefObject). Then I just pass the "ExecutionData[] data" parameter to the "ExecutionHarnessProxy.Execute()" method. This guy then calls "ExecutionHarness.Execute()" and all is good.

My problem now is that whenever I pass my array of data to the proxy class, it takes FOREVER. The ExecutionData class has the [Serializable] attribute, and functionally it all works, but I was wondering if there is any way to speed this up.

  1. Could it be faster if I did the serialize/deserialize myself, on both sides of the AppDomain boundary?
  2. Is all of this time spent doing serialization? or is it just the transfer of the serialized data between AppDomains?
+1  A: 

It's difficult to know without more information, but from what you're describing, I'd suspect the ExecutionData array is the culprit.

Each time you call a method that requires this data, you will serialize the data into the AppDomain, and potentially back out as well. If this array is large, that can eat up quite a bit of processing time.

It would be better if the data could be loaded directly in each AppDomain, and only pass the execution results back into your main AppDomain. If you can avoid passing arrays of data between the AppDomains, you will likely dramatically speed up the process.

Reed Copsey