[Ironruby-core] Code Review: OverloadInfo

Tomas Matousek Tomas.Matousek at microsoft.com
Fri Feb 5 17:38:48 EST 2010

tfpt review "/shelveset:OverloadInfo8;REDMOND\tomat"

Affects DLR, Python, Ruby.

The OverloadResolver was performing quite a bit of reflection (mostly calling ParameterInfo.IsDefined) which turned out to consume about 15% of RoR request time.
This change introduces OverloadInfo abstraction which captures all properties of a method that are needed to perform overload resolution. The default implementation (ReflectionOverloadInfo) holds on a MethodBase and uses reflection to determine these properties. The implementation caches information that is expensive to retrieve via reflection. The OverloadInfo is a public abstract class and could be implemented by languages so that almost no reflection is needed at runtime. The ultimate goal is to remove OverloadResolver's dependency on Reflection types (other than Type). This change goes half way - it abstracts away reflection in the first phase of overload resolution (building target sets). More work needs to be done to remove the dependency on Reflection completely in the expression building phase. It would also require some breaking changes in DLR so we keep that part post IronRuby v1.0.

IronRuby implements LibraryOverload subclass of OverloadInfo. Library initializers generator performs custom attribute reflection on library methods and compresses the retrieved information to 31 bits. It imposes a limit of 15 parameters on library methods (more parameters can be supported if needed). The flags are then used at overload resolution time instead of calling ParameterInfo.IsDefined.

The difference in perf:
> ir.exe -X:CompilationThreshold 2 test.rb

// before change
Initialized in 7.8005s
10000 requests: 289 requests per second
Peak working set: 217MB

// after change
Initialized in 7.64449s
10000 requests: 337 requests per second
Peak working set: 216MB

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100205/7c2e8bf0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OverloadInfo8.diff
Type: application/octet-stream
Size: 776933 bytes
Desc: OverloadInfo8.diff
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100205/7c2e8bf0/attachment-0001.obj>

More information about the Ironruby-core mailing list