Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the minimum Cross AppDomain communication performance penalty?
    text
    copied!<p>I am trying to minimize the performance penalty of communicating across AppDomains in the same machine. In my toy example, Class A is loaded in AppDomain 1. It creates an AppDomain 2 and loads there an instance of Class 2 (Class 2 inherits from MarshalByRef) getting back a proxy. Then Class 1 calls repeatedly a method on the proxy that returns no values.</p> <p>I get the following results:</p> <ol> <li>No AppDomains, both classes are loaded in the same AppDomain and the first calls repetedly the method on the second (the method has no parameters): <strong>24 million</strong> method calls/sec</li> <li>Two AppDomain as described above, method has no parameters or "bleeding" string parameters: <strong>340.000 methods calls/sec</strong></li> <li>Two AppDomains as described above, one serializable parameter (array of two strings): <strong>64.000 method calls/sec</strong></li> </ol> <p>Although I understand the performance penalty between 2 and 3 (serialization), I really don't understand <strong>why I am 100 times slower from case 1 to case 2</strong>. To my understanding, once the proxy is created all subsequent method invocations must be really fast since no data are being marshalled from one AppDomain to the other. Does anybody now why communicating across AppDomains is so slow? Am I doing something wrong?</p> <p>PS1. The only tip that I have on this is <a href="http://blogs.msdn.com/cbrumme/archive/2003/06/01/51466.aspx" rel="noreferrer">here</a>: "And the cost of crossing an AppDomain boundary is embarrassing.". I was guessing he refers to serialization...</p> <p>PS2. I don't count the AppDomain or Proxy creation time (my benchmarks start in the first method invocation)</p> <p>PS3. I am using .NET 3.5 in a WinXP SP3 machine. I also tried .NET 4.0 Beta 1 with no significant differences.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload