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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2380417.patch | 8.68 KB | dawehner |
Comments
Comment #1
moshe weitzman commentedComment #2
catchSo 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
Comment #3
dawehnerRegarding 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.Comment #4
dawehnerHere is a quick try for me previous IDEA
Comment #5
fabianx commentedComment #7
chx commentedWhat 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%.Comment #8
catchWhile 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.
Comment #9
moshe weitzman commentedThis is using APC classloader with apc.stat=0, same as #2370667: [Meta] user/password flame graph.
Comment #10
dawehnerFiled an issue for that patch: #2381505: Unserialize preloaded routes on the fly
Comment #11
moshe weitzman commentedI 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
Comment #12
dawehnerWe have one for almost all the things already.
Comment #13
damien tournoud commentedOn the left-side of the graph, the initialization of
ApcuBackendFactoryusesconf_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.Comment #14
damien tournoud commentedIt would be useful to get a graph excluding
Symfony\Component\DependencyInjection\Container::getandDrupal\Core\DependencyInjection\Container::get. There might be ways to micro-optimize those, but they just add unnecessary noise on those graphs.Comment #15
dawehnerNice observation!
Alright, lets fix more of the usecases of
config_path(): #2384675: Deprecate conf_path()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.
Comment #16
damien tournoud commentedOf 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).
Comment #17
dawehnerOh yeah, I don't disagree with you at all here.
@moshe weitzman
Can you filter out some functions?
Is the way to do it.
Comment #18
Crell commentedSome related discussion in #2370667-19: [Meta] user/password flame graph and following (regarding Container::get())
Comment #19
moshe weitzman commentedI can't filter out functions easily. We are using xhprof_sample_enable(), not xhprof_enable().
Comment #20
berdirOn automated cron, you possibly want to disable poormans cron completely for this? Any serious site is going to do run cron manually.
Comment #21
berdirNo 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.
Comment #35
smustgrave commentedThank 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!
Comment #36
smustgrave commentedWanted to bump this 1 more time before closing.
Comment #37
berdirI 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.