Problem/Motivation
\Drupal\Core\DependencyInjection\Container::get()
is called repeatedly for service IDs that are already instantiated. That is as expected, but given that, it makes a measurable difference to have it return as fast as possible in that situation.
On a fresh install of the Standard profile, accessing the front page (View with no content) by anonymous, using ab
, I see a 1% improvement with this patch (256ms vs. 259ms). Note: I think ab
is a better measure here than xhprof, since I think xhprof adds overhead to stack calls in order to measure them, and with this patch in particular, I think that would distort the results.
Proposed resolution
See the patch at #15, but also note those problems.
Remaining tasks
Determine a solution to the aforementioned problems and fix them.