[Mono-devel-list] Cross application domain call optimization

Lluis Sanchez lluis at ximian.com
Mon Oct 18 06:42:25 EDT 2004


> > However, there is a drawback: we need to generate two additional methods
> > for each remotable method. As an example, a monodevelop run creates
> > around 80 wrapper methods + 80 helper methods, averaging 435 bytes of IL
> > per couple, which means 34kb of IL code (plus the memory of internal
> > data structures). And all this is dead code, since monodevelop does not
> > use app domains, but the wrappers are generated for every call to a non-
> > virtual MarshalByRefObject method. The reason is that those calls are
> > made through the remoting-invoke-with-check wrapper, wich has a
> > reference to the other wrappers.
> 
> Nope, this doesn't have to be done. What we do is: you emit this code:
> 
> call trampoline
> 
> That method will go into the runtime, generate the IL for the wrapper
> method, and jit it. Then, it takes that jitted code and dynamically
> patches the address so that it refers to the new method. This avoids the
> lookup.

Yes, that is what I was talking about in the end of my mail. This would
solve the memory issue without losing performance. But it is not yet
supported.

> 
> One other option would be to always call functions in MBRO's virtually.
> It may end up being faster than having to do the call, etc.
> 
> Ok, now specific patch comments:
> 
> 
> > +	object get_xappdomain_target (RealProxy rp)
> > +	{
> 
> Why not actually write this method in C# and call it from the marshal
> stuff?

Yes, it can be done.

> 
> 
> > +	Exception mono_serialize_exception (Exception ex)
> > +	{
> > +		Exception loc_exc = ex;
> > +		byte[] loc_data;
> > +		int retry = 4;
> > +		
> > +		do {
> > +			try {
> > +				mono_thread_force_interruption_checkpoint ();
> > +				loc_data = RemotingServices.SerializeObject (loc_exc);
> > +				return loc_data;
> 
> Same comment here. Also, why do we need the interruption checkpoint?

While doing the domain transition the thread should only be able to be
aborted at some specific safe points. That's one of them.
However, there is an issue that I need to fix regarding this, since
although the other wrappers can be protected against interruptions, this
method is still not.

Lluis.




More information about the Mono-devel-list mailing list