[wp-trac] [WordPress Trac] #58674: Fix incorrect hook being used as separator between `wp-before-template` and `wp-template` metrics in automated performance tests

WordPress Trac noreply at wordpress.org
Thu Jun 29 20:37:12 UTC 2023


#58674: Fix incorrect hook being used as separator between `wp-before-template` and
`wp-template` metrics in automated performance tests
------------------------------+-------------------------
 Reporter:  flixos90          |      Owner:  (none)
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  6.3
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:  needs-patch
  Focuses:  performance       |
------------------------------+-------------------------
 Comparing the
 [https://docs.google.com/spreadsheets/d/1cViAPPq4tSsmEoM7D2INwoQUNMlNpxL3kjvhyA8-7xQ/edit#gid=1831125546
 WordPress 6.3 Beta Server-Timing benchmarks] with the
 [https://www.codevitals.run/project/wordpress automated performance
 dashboard], it shows that the `wp-before-template` and `wp-template`
 metrics for classic themes are clearly off in one or the other.

 While it is expected that values may differ notably between environments,
 the relationship between them should always be roughly the same - which is
 not the case here: `wp-before-template` has a much higher value in the
 benchmarks, but a much lower value in the dashboard.

 After looking at the implementation, it appears that this difference is
 caused by the underlying tools using a different hook: The Performance Lab
 plugin which powers the benchmarks relies on the `template_include` filter
 (https://github.com/WordPress/performance/blob/2.4.0/server-
 timing/defaults.php#L63), while WordPress core's performance tests rely on
 the `template_redirect` action (https://github.com/WordPress/wordpress-
 develop/blob/60b3fe7997d1299b83942c0162020df0483622a3/tests/performance
 /wp-content/mu-plugins/server-timing.php#L4).

 Given that the `template_include` filter is the very last hook before
 template output starts, the core implementation should be adjusted to use
 that filter instead of the `template_redirect` action, as that action runs
 before the template loading starts which has a notable cost and is not
 part of template rendering.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58674>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list