A flame graph of the /hi route. Its controller returns a 'hi' Response, so block building and HTML rendering are skipped. See #2368275-32: EntityRouteEnhancer and ContentFormControllerSubscriber implicitly depend on too many services for the code for this route.

To understand flame graphs, see the issue summary at #2370667: [Meta] user/password flame graph.

#2353357: hook_stream_wrappers_alter() should be removed as it is broken since modules are not loaded on demand is also related, because it removes the only reason the stream wrapper needs the module handler and it removes the broken alter() call there. Current patch does not yet remove the injected module handler, though. Also, it will allow (the current patches are experimenting with that) to avoid loading module files for routes like this, where the theming layer is not needed.

CommentFileSizeAuthor
#4 2380417.patch8.68 KBdawehner

Comments

moshe weitzman’s picture

Issue summary: View changes
catch’s picture

So that looks like mostly known issues, but to document them:

- routing event listener dependencies
- logger should be lazy service
- route preloading (while I think we need it, it might be worth an issue to make sure that's as optimized as it should be)\
- path alias whitelist similar comments to route pre-loading except we also have that in 7.x
- automated cron looks suspicious here too

dawehner’s picture

- route preloading (while I think we need it, it might be worth an issue to make sure that's as optimized as it should be)\

Regarding that, it takes 10% on the unserialize() call. Even route preloading is nice, I wonder whether we could avoid the unserialization for the routes we don't use.

dawehner’s picture

StatusFileSize
new8.68 KB

Here is a quick try for me previous IDEA

fabianx’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: 2380417.patch, failed testing.

chx’s picture

What jumped at me is the insane amount of services we load -- that requires finding the class and instantiating the class. I wonder how this would look with an APCu classloader to kill loadFile. And/or an xhprof/cachegrind number for how much time is spent in Composer\Autoload\ClassLoader::loadClass. I have a bad suspicion of 25-30%.

catch’s picture

While it's useful to remind everyone just how bad the default composer classloader is for performance, it'd be more useful for the flamegraphs if we always use the APC class loader. Not clear from the issue summary what the case is here.

moshe weitzman’s picture

This is using APC classloader with apc.stat=0, same as #2370667: [Meta] user/password flame graph.

dawehner’s picture

moshe weitzman’s picture

I refreshed the flame graph in the IS. I was not configuring APC Classloader correctly in my settings.php. The route 'hi' is faster now (55ms).

Would be good to get hyperlinks on any open issues mentioned in #2

dawehner’s picture

We have one for almost all the things already.

damien tournoud’s picture

On the left-side of the graph, the initialization of ApcuBackendFactory uses conf_path() instead of injecting the kernel which leads to (1) a call to \Drupal::hasRequest() (really slow, and totally unnecessary, just call \Drupal::request() and catch the exception, please) followed by a second construction of the request object from the globals.

damien tournoud’s picture

It would be useful to get a graph excluding Symfony\Component\DependencyInjection\Container::get and Drupal\Core\DependencyInjection\Container::get. There might be ways to micro-optimize those, but they just add unnecessary noise on those graphs.

dawehner’s picture

Nice observation!

On the left-side of the graph, the initialization of ApcuBackendFactory uses conf_path() instead of injecting the kernel which leads to (1) a call to \Drupal::hasRequest() (really slow, and totally unnecessary, just call \Drupal::request() and catch the exception, please) followed by a second construction of the request object from the globals.

Alright, lets fix more of the usecases of config_path() : #2384675: Deprecate conf_path()

It would be useful to get a graph excluding Symfony\Component\DependencyInjection\Container::get and Drupal\Core\DependencyInjection\Container::get. There might be ways to micro-optimize those, but they just add unnecessary noise on those graphs.

While this would be helpful, we have to keep in mind that initializing unnecessary dependencies is a thing we should really try to avoid, if possible, see the proxy issue.

damien tournoud’s picture

While this would be helpful, we have to keep in mind that initializing unnecessary dependencies is a thing we should really try to avoid, if possible, see the proxy issue.

Of course. But those functions are not slow by themselves. Keeping them on the graph will lead to focusing on the wrong things and losing track of the big picture (see #2370667-19: [Meta] user/password flame graph for an example).

dawehner’s picture

Oh yeah, I don't disagree with you at all here.

@moshe weitzman
Can you filter out some functions?

xhprof_enable(0, array('ignored_functions' =>  array('call_user_func', 'call_user_func_array')));

Is the way to do it.

Crell’s picture

Some related discussion in #2370667-19: [Meta] user/password flame graph and following (regarding Container::get())

moshe weitzman’s picture

I can't filter out functions easily. We are using xhprof_sample_enable(), not xhprof_enable().

berdir’s picture

Issue summary: View changes

On automated cron, you possibly want to disable poormans cron completely for this? Any serious site is going to do run cron manually.

berdir’s picture

No idea, but it eat the second half of my comment.

Also interesting: https://www.drupal.org/node/2353357

- Removes only reason for module handler in stream wrapper (although it will replace it with an event, which might be just as expensive?), but it will also allow to avoid loading the modules for routes like this. But that won't help much on most routes that invole theming.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

smustgrave’s picture

Wanted to bump this 1 more time before closing.

berdir’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

I think it's fine to close this. There were actionable issues that were done, we have performance testing now, which doesn't provide exactly the same data, but whatever was shown in this specific flamegraph is long outdated. We can always create new issues if we spot things.