Problem/Motivation
This is a micro-optimisation but we're making thousands of calls to \Drupal\Component\DependencyInjection\Container::get() when we return an uncached page and on every call we do
if ($this->hasParameter('_deprecated_service_list')) {
if ($deprecation = $this->getParameter('_deprecated_service_list')[$id] ?? '') {
@trigger_error($deprecation, E_USER_DEPRECATED);
}
}
which we actually only need to do once when we instantiate the service.
Steps to reproduce
Get any service from the container twice.
Proposed resolution
Move the code to after the early returns. On a post request from the autosave module this reduces the calls to Drupal\Component\Dependency…tion\Container::getParameter() from 2890 to 378. Note this is a micro-optimisation because the calls are very cheap.
Remaining tasks
User interface changes
None
Introduced terminology
N/a
API changes
None
Data model changes
None
Release notes snippet
N/a
Issue fork drupal-3560108
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3560108-do-not-make
changes, plain diff MR !13964
Comments
Comment #2
alexpottComment #3
alexpottComment #5
smustgrave commentedAppears to be 1 suggestion in the MR @alexpott thoughts?
Comment #6
alexpottI think the suggestion broke the MR :)
" This test is not expected to perform assertions but performed 1 assertion"
Comment #7
alexpottI've reverted @longwave's suggestion - this should be all good now.
Comment #8
longwaveOops although it would be good to know what that is as tests should not assert by default, which is why that method exists!
Comment #9
smustgrave commentedSeems feedback for this one has been addressed then:)
Comment #11
catchThis looks good.
Tagging for needs follow-up to see if we can figure out how to make @longwave's suggestion work or why it definitely can't work.