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
In shortcut_preprocess_page
$link = current_path();
if (!($url = \Drupal::pathValidator()->getUrlIfValid($link))) {
// Bail out early if we couldn't find a matching route.
return;
}
because that can happen how?
Proposed resolution
Replace $url
with the route match. Trivial solution, instant win!
Comment | File | Size | Author |
---|---|---|---|
#10 | perf_shortcut_reruns-2351411-10.patch | 1.3 KB | davidhernandez |
#2 | shortcut_wat.patch | 1.28 KB | chx |
Comments
Comment #2
chx CreditAttribution: chx commentedComment #3
Fabianx CreditAttribution: Fabianx commentedLooks great to me. I assume this has adequate test coverage already.
So RTBC once tests pass.
Comment #5
Fabianx CreditAttribution: Fabianx commentedComment #6
dawehnerFor a anonymous user with shortcut permissions this safes itself 1%:
Comment #7
benjy CreditAttribution: benjy commented@dawehner, care to share the contents of benchmark-branches.sh ?
Comment #8
Fabianx CreditAttribution: Fabianx commented@benjy:
https://github.com/LionsAd/xhprof-kit/blob/master/benchmark-branches.sh
See also:
https://drupal.org/contributor-tasks/profiling
I have written it originally for the Twig initiative.
You will need to hack it for uprofiler or any non-standard URL for the installation (see https://github.com/LionsAd/xhprof-kit/blob/master/find-min-web.sh and change 127.0.0.1 with drupal8.local or such).
In find-min-web.sh you can also specify the number of runs.
The nicest thing that dawehner currently does not use is:
You can get an API key from me and then others can check the XHProf run online. (see upload-run.sh and upload-bench.php to do it manually)
Comment #9
dawehner@benjy
For xhprof have a look at https://github.com/dawehner/xhprof-kit/tree/uprofiler
@Fabianx
Contact message sent.
Comment #10
davidhernandezSee if this is green.
Comment #11
Fabianx CreditAttribution: Fabianx commentedNice work!
Comment #12
Fabianx CreditAttribution: Fabianx commented10 shortcuts, Drupal Admin interface exposed for anonymous user, 100 iterations, basic front-page, PHP 5.5 with opcache
TL;DR: Saves 858 function calls, -1%, -1,932 ms
### FINAL REPORT
=== baseline-2351411-8.0.x..8.0.x compared (545228c9d3459..54522a97f422e):
ct : 83,410|83,410|0|0.0%
wt : 193,102|192,792|-310|-0.2%
mu : 23,410,264|23,410,264|0|0.0%
pmu : 23,490,240|23,490,240|0|0.0%
=== baseline-2351411-8.0.x..issue-2351411--shortcut-faster compared (545228c9d3459..54522ab81cc00):
ct : 83,410|82,552|-858|-1.0%
wt : 193,102|191,170|-1,932|-1.0%
mu : 23,410,264|23,367,152|-43,112|-0.2%
pmu : 23,490,240|23,447,008|-43,232|-0.2%
=== SUM: 8_0_x-summary..issue-2351411--shortcut-faster-summary compared (54522ade70ee0..54522ae62234d):
ct : 8,341,000|8,255,200|-85,800|-1.0%
wt : 20,264,594|20,128,144|-136,450|-0.7%
mu : 2,341,026,712|2,336,715,584|-4,311,128|-0.2%
pmu : 2,349,031,488|2,344,693,888|-4,337,600|-0.2%
---
ct = function calls, wt = wall time, cpu = cpu time used, mu = memory usage, pmu = peak memory usage
### XHPROF-LIB REPORT
Comment #13
Fabianx CreditAttribution: Fabianx commentedRTBC
Comment #14
dawehner+1!
Comment #15
alexpottThis issue is a major task that will improve performance significantly and the disruption it introduces is limited. Per #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase?, this is a good change to complete during the Drupal 8 beta phase. Committed c0459a1 and pushed to 8.0.x. Thanks!
Comment #17
davidhernandezWow, that was all rather ... fast. :)
Comment #18
Wim LeersYay for improving Shortcut module!