# Code Review: OverloadInfo

**URL:** <https://www.ruby-forum.com/t/code-review-overloadinfo/183009>\
**Category:** IronRuby\
**Created:** [February 5, 2010, 11:39pm UTC](https://www.ruby-forum.com/t/code-review-overloadinfo/183009 "2010-02-05T23:39:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grujildo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@grujildo](https://www.ruby-forum.com/u/grujildo)\
**Post date:** [February 5, 2010, 11:39pm UTC](https://www.ruby-forum.com/t/code-review-overloadinfo/183009/1 "2010-02-05T23:39:50Z")

</div>

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

Tomas
