[Mono-devel-list] System.Reflection Performance

Paolo Molaro lupus at ximian.com
Fri Jan 2 09:06:52 EST 2004


On 01/02/04 Ben Maurer wrote:
> So, it is quite obvious that the GetType is the bulk of the problem.

This was already discussed a few months ago. At the time I described how
to fix the issue, but no enteprising mono developer showed up, so I
committed my ten line patch today.
Remoting should see a sensible speedup, too, since it uses GetType in
places.

> I am wondering if any of the runtime gurus can think of ways to make
> GetType faster. GetType is by no means *fast* in MS, it is not designed
> to be. However, it seems reasonable that it should be a tad bit faster
> than this.

The current impl is probably as fast as it can be (with about 30 bytes
of memory overhead per vtable: we'll see later if it makes sense to
have a slightly slower implementation and to delay allocate the memory).

> As a side note, I did a quick test on the Invoke call in MS.net, it is
> pretty clear that they call the Binder iff the parameter type does not
> match exactly (I tested by making a Binder that would always return 500,
> and then called a method with the sig (int,int) with params (byte,int).
> The first parameter was passed as 500, the second was unmodified.) So,
> it appears we could change Invoke to do the check in C. In C we would be
> able to take alot of shortcuts (not allocating the params array, quicker
> type operations, etc, etc). I think this would be an easy way to fix the

The Binder code needs some work to better match the MS implementation: I
suggest not trying to optimize it until we actually cover all the
corner cases and your suggestions can only be implemented in some
special cases, anyway.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list