[Mono-devel-list] [PATCH] Attribute speedup

Ben Maurer bmaurer at users.sourceforge.net
Sun Feb 29 19:00:42 EST 2004


Attached is a patch that significantly speeds up operations on Custom

In a nutshell, what the patch does is to move the entire operation of
querying for custom attributes into reflection.c. This has a few
      * We avoid allocating arrays to store the result for each level of
        inheritance. Instead we do it with a GSList, which doesnt need
        the GC scanning, etc.
      * We avoid creating attributes that we are not going to return.
      * In the IsDefined method, we dont have to create any attributes
        *at all*.

These benefits are very powerful. I was able to get 10x-60x perf in a
program that just looked at custom attributes. However, in real life
this also pays off. gnunit was able to load the tests for corlib *much*

Also, it turns out that before we had a memory leak here, this fixes the
problem by not allocating the memory in the first place.

This patch also has a fix for
http://bugzilla.ximian.com/show_bug.cgi?id=54945. The fix is that we use
the ->parent of the MonoClassField rather than using the ->klass of the
reflection object. I am not sure if this is really covering up a bigger
problem, but it seems to work ;-).

-- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: corlib-attribute-speedup.patch
Type: text/x-patch
Size: 7220 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040229/68699d4b/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mono-attribute-speedup.patch
Type: text/x-patch
Size: 27694 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040229/68699d4b/attachment-0001.bin 

More information about the Mono-devel-list mailing list