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