Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
As research in #2407177: Profile to determine which services should be lazy has shown, we initialize a couple of services, without actually using it.
Proposed resolution
Let's mark them lazy.
Doing so yields a nice performance win — quoting @dawehner in #2407177-24: Profile to determine which services should be lazy:
Did some quick profiling for the following usecases:
- The frontpage without any content: 6.8% https://blackfire.io/profiles/compare/5e9aabb1-fe32-48b8-b722-b8f40387f3...
- admin/reports/status/php: 8.5% https://blackfire.io/profiles/compare/513189ff-79ad-48af-9626-e37eb9a699...
- retrieve /node/1 via REST (hal_json) 3% https://blackfire.io/profiles/compare/390c5a54-9476-4e59-a3f0-e2055d7931...
I'm have profiled the entire request, with opcache as well as the apcu based classloader enabled.
Absolute numbers
Scenario HEAD PATCH Default frontpage, no content, anonymous user 254ms 236ms admin/report/status/php, anonymous (bootstrap + phpinfo()) 31ms 28.3ms REST request: /node/1 with hal_json 68.4ms 65.7ms
Remaining tasks
None.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#4 | interdiff.txt | 775 bytes | dawehner |
#4 | 2454287-4.patch | 5.15 KB | dawehner |
#1 | 2454287-1.patch | 5.91 KB | dawehner |
Comments
Comment #1
dawehnerHere is the last patch from the other issue.
Comment #2
Wim LeersWe never called
Timer::stop()
, so this is probably okay. OTOH it makes it more difficult for e.g.webprofiler.module
to do its work?I suppose this is to avoid loading this class. That makes sense. But it seems out of scope WRT the issue title?
Comment #3
Wim LeersUpdated IS to include profiling data.
Comment #4
dawehnerDevel used to use it, BUT, they can also use one of the really early events being fired (which is what webprofiler is afaik doing). The usecase of devel is not to profile the bootstrap but rather to give a time for the full page request, so the time difference from super early bootstrap to first even fired, is not a lot.
Alright, reverted that bit, but yeah I think its simply not something you really need.
Comment #5
Fabianx CreditAttribution: Fabianx for Drupal Association commentedRTBC, lets add some lazyness!
Comment #6
Wim LeersRTBC +1
#4: thanks for that explanation. If you prefer, I'm fine with doing that hunk in this issue, since devel was the only user, and it now has an alternative.
Comment #7
dawehnerAs fabian said yesterday, the problem is actually not the classloading (if you have opcache enabled) but the construction of the objects itself,
so I think keeping it in here is totally fine, but in general I'd also like to remove it in order to clean up
DrupalKernel
a bit.Comment #8
Wim LeersSounds good :)
Comment #9
alexpottZero disruption and good for performance - what is not to like!. Committed 23ed78e and pushed to 8.0.x. Thanks!