Code Review: SingletonOptimizations

tfpt review “/shelveset:SingletonOptimizations;REDMOND\tomat”

Optimizes allocation of singletons. Module singletons could be allocated
lazily. We used to eagerly allocate a singleton for each allocated
RubyModule. This is only necessary for classes. Their singletons are
chained in the inheritance hierarchy parallel to the hierarchy of the
classes. A module doesn’t have a super-class and thus we don’t need to
create a singleton for it unless it has some members. Consequently 2
modules of the same meta-module type with no singletons can share the
same call-site rules. This sharing significantly improves RoR request
time and reduces working set since the request processing code is using
such modules.

Also fixes a few related minor bugs.

Previously:
Initialized in 7.64449s
10000 requests: 337 requests per second
Peak working set: 216MB

Adaptively compiled:
Initialized in 6.966271s
10000 requests: 1132 requests per second
Peak working set: 91MB

Compiled:
Initialized in 26.106867s
10000 requests: 1243 requests per second
Peak working set: 89MB

MRI:
Initialized in 2.82389s
10000 requests: 1623 requests per second

Tomas